Welcome Guest, Not a member yet? Register   Sign In
php date
#1

[eluser]1mr3yn[/eluser]
I just wanted to get the number of week in a month.

Code:
echo "Process Date: " . date("Y-M-d"), "<br>";    
            
    if ( date('l') == 'Tuesday' )    {
      echo "Cycle Date: " . date("Y-M-d"),"<br>";
    }
    else{
       echo "Cycle Date: " . date("Y-M-d",strtotime("next Tuesday")), "<br>";            
    }

im done in getting the next tuesday.
but the problem is, i cant find the algorithm that will post the week number.
Quote: For example:
September 16, 2009 is in '3rd week' of September.(something like that)

Thanks Guyz!
#2

[eluser]davidbehler[/eluser]
Check the documentation: http://de3.php.net/manual/en/function.date.php
Code:
date('W');
returns the number of the week. "Only thing" you have to do is determine wether to use 'st', 'nd', 'rd' or 'th' Wink
#3

[eluser]sophistry[/eluser]
um, is this a trick question?

i'm pretty sure you can divide the day number by 7 to get the week number - if I remember correctly from my school days. ;-)

EDIT: darn, replied too quickly... it *was* a trick question... you need the day-monthstart offset too.




Theme © iAndrew 2016 - Forum software by © MyBB