PHP date functions
I wrote a scrpit to dispay the time between two dates in YY years, MM months, DD days, HH hours, MM minutes, and SS seconds.
The script works fine for all dates after the UNIX epoch. The mktime() and date() functions are messing me up. I wrote a small test script and got the following results. PHP Code:
Code:
epoch1 = December 31st, 1969 - -1 Any thoughts? |
What happens is 1970 is taken as the reference for caluclation of date.
Maybe incrementation of this time takes place until the corresponding month,day,year specified by mktime are got . If i remember right , epoch returns the seconds passed from Jan 1st,1970 to time specified by mktime. Hence when you specify the date of less than that of 1970..then the correct time cannot be calculated ....I suppose I have made myself clear. Epoch returns the value of secs_passed = secs(date_specified_by_mktime)-secs(1970,Jan 1) where secs(1970,Jan1 ) is taken as starting value =0; if secs_passed is negative i.e, date_specified < 1970,Jan1 then -1will be printed |
All times are GMT -5. The time now is 07:20 AM. |