RE: Date Manipulation

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

 



In addition to Matthew's response...

Strtotime() and mktime() both return a serial date.  That's the
"1101945775" number you got.  To get this back to a YYYYmmdd format that
you seem to be trying to do with mktime(), you want to use date() as
Matthew suggested.  Again, I think examples help more than "RTFM":

date("Ymd",strtotime("now"));

mktime() and strtotime() produce the same output which is not a
human-readable date format.  So basically, in your example below, you
told it that you wanted:

The serial date (mktime()) of hour "Ymd" (evaluates as 0 I believe),
minute "1101945775", with seconds, month, day and year all empty.  I
think the leaving them empty is ok since they're optional from right to
left, and the excessive number of minutes probably wouldn't be a big
deal (unless it goes past the maximum date rate, which looks like what
it's doing).  Let's do a quick calc:


Looks like the max number that mktime() can produce is:
2147483647

This is 1/18/2038 22:14:07

If you take your serial date "1101945775" and pipe it into the minutes
section of mktime(), it'll produce that number times 60 (60 seconds in a
minute) and try to get that date.  This produces a number:

66116746500

Significantly bigger than the max serial date for Windows mentioned
above.


Long answer to maybe help you understand how it all works.


Btw: The serial date is the number of seconds since the beginning of the
"Unix Epoch" (# of secs since January 1, 1970 that is... Hey, time's
gotta start somewhere eh?)

Hope this helps clarify mktime(), strtotime() and date().

-TG

> -----Original Message-----
> From: Christopher Weaver [mailto:booktues@xxxxxxxxx] 
> Sent: Wednesday, December 01, 2004 7:13 PM
> To: php-general@xxxxxxxxxxxxx
> Subject: Re:  Date Manipulation
> 
> 
> This code:
> 
> echo strtotime("now");
> echo mktime("Ymd", strtotime("now"));
> 
> is producing this result:
> 
> 1101945775
> Warning: mktime(): Windows does not support negative values for this 
> function ...
>  -1
> 
> What am I doing wrong?
> 
> Thanks again.

-- 
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