note 68937 deleted from function.date by bobby
| From: | bobby@php.net | Date: | Thu, 07 Sep 2006 18:14:48 +0000 |
| Subject: | note 68937 deleted from function.date by bobby | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-116859@lists.php.net to get a copy of this message | ||
Note Submitter:
----
Hey. Just for the ones of you that want a date format equal to N but only have earlier versions of
PHP (less than 5.1) installed on the server. Here's a method of converting the w date argument
and get the day of the weekday in N format.
<?php
function get_weekday( $stamp )
{
$a = date( "w", $stamp ) - 1;
if ( $a == -1 )
$a = 6;
return ++$a;
}
?>
Should return the same value as it's 5.1 version big brother below.
<?php
$weekday = date( "N", $stamp );
?>
Now you'll get a range from 1-7 according to which day you're feeding the function by
Epoch secs. Good luck!