Jump to content

Recommended Posts

I live in the UK, i am within the GMT (with daylight saving time ie 1 hour difrence between summer and winter)

 

Should i be using GMDATE and GMMKTIME or DATE and MKTIME... for all my date and time functions?

 

I have been having a number of problems with page i have been working on with dates.

 

Also does GMMKTIME just minus a hour from the MKTIME over the summer months?

 

the problem i am having, if someone requests a holiday eg in June and the request is made in Jan, since the clocks have gone back these enteries have lost a hour?

 

 

Link to comment
https://forums.phpfreaks.com/topic/179339-gmmktime-or-mktime/
Share on other sites

You would need to provide a specific example of what values are not working and the code that produces the problem.

 

Uniix timestamps are problematic for several reasons. The biggest one is that you must convert them into a human readable form at some point in time. In php or mysql, unless you use the GMxxx functions, this conversion is dependent on the timezone your web server or mysql server has been configured for (php and mysql have separate timezone settings) at that time the conversion takes place and it is also dependent on an accurate DST setting. Many locations have been changing the DST start and end dates. Both php and mysql have separate DST databases that must be kept up to date in order to give a correct conversion.

 

I don't know if the conversion errors you got in your code were due to different timezone settings at the time the dates were stored vs when they were retrieved (perhaps even using GMxxx functions at one point and non GMxxx functions at another) or if your DST start/end changed at your timezone setting and your DST database(s) is not up to date or if you are doing date/time math by adding a fixed number of seconds per day that does not take into account the loss/gain when DST changes, but all of these conversion problems can be avoided if you don't store date/datetime values using Unix Timestamps. If you store them using DATE (YYYY-MM-DD) or DATETIME (YYYY-MM-DD HH:MM:SS) data types, they will always be the value you store. No conversion is necessary to use them and to just change the format (which is not the same thing as converting the value to/from a Unix Timestamp) to something else (such as dd/mm/yyyy) can be done easily and quickly.

Link to comment
https://forums.phpfreaks.com/topic/179339-gmmktime-or-mktime/#findComment-946277
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

×
×
  • 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.