RE: mktime

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 13 September 2005 00:08, Dan Brow wrote:

> A little confused with mktime, I'm trying to get how many
> days are in a
> year.
> 
> $year = "2006";
> $epoch = mktime(0, 0, 0, 1, 0, $year); // I have to have 1

You're asking for the 0th day of the first month here, which is (guess what!) the last day of *last* year.  If you want to get the last day of *this* year, you need to ask for the 0th day of *next* year; or, more trickily, the 0th day of the 13th month of *this* year! (Note: I haven't tested this, but logically it should work... ;)  So, either of these should get what you want:

  $epoch = mktime(0, 0, 0, 1, 0, $year+1); 
  $epoch = mktime(0, 0, 0, 13, 0, $year); 

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: m.ford@xxxxxxxxxxxxxx
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux