Page 1 of 1

PHP day difference calculation problem, occur on diff. month

Posted: Wed Mar 31, 2004 8:32 pm
by d0rr
guys, i need some help on PHP day difference calculation..

i have my date format as in YYYYMMDD, for instance 1st april 2004 = 20040401

it works fine if it is within the same month.. for instance:
20040310 - 20040305 = 5 days gap.. (since i am using simple subtractive code)

however, when it comes to different month, it tends to mix up:
20040430 - 20040330 = 100 days gap!! (suppose to be 1 month, 30 days!)

anyone can help me solve this problem? it's kinda urgent~ :? :?

Posted: Thu Apr 01, 2004 5:02 am
by kettle_drum
Store your date as the unix epoch time, then subtract the two dates, and your left with the number of seconds between the two dates to do what you like with.