Jump to content

Timestamp use


simpli
 Share

Recommended Posts

Hi, I have been trying to get the difference in days (or week/month/year) between two dates but I haven't been able to make it work so I'm considering doing it with timestamps. This brings a question to me. If I use a timestamp, am I still going to have to worry about DST (daylight saving times)  and leap years? If so anyone can tell me how I should deal with them.

Any help is wanted I am really stuck and dont know what to do / where to turn to get a coherent way to calculate those differences.

Thanks in advance,

JR

Link to comment
Share on other sites

I understand how to calculate the days but my question was more what happens with DST and leap years. Because obviously if there was a leap year between the two dates i used to calculate the timestamp difference, it's 366 days that's gonna give me a year not 365.

Link to comment
Share on other sites

I assume php knows about that already. Why, have you seen a problem related to leapyears? The code I given converts to timestamp. Timestamp is the number of seconds since 1/1/1970. As its the number of seconds (and infact correct) it should know if it was a leap year or not and add/deduct a day?

Link to comment
Share on other sites

Hi Teddy,

I dont think it does. The timestamp returns the number of seconds and that is good and does not change whether it's a leap year or not. The problem is if I want to calculate years I have to count 366*24*60*60 and leap years and 365*24*60*60 in non leap years.

JR

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.