nezbo Posted October 28, 2009 Share Posted October 28, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/179339-gmmktime-or-mktime/ Share on other sites More sharing options...
pastcow Posted October 28, 2009 Share Posted October 28, 2009 I always stick with gmmktime, it always gives the time in GMT - this might not be the best thing to do but I like it as it keeps everything simple. eg the timestamp 0 is 1970 not 1969 Quote Link to comment https://forums.phpfreaks.com/topic/179339-gmmktime-or-mktime/#findComment-946262 Share on other sites More sharing options...
PFMaBiSmAd Posted October 28, 2009 Share Posted October 28, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/179339-gmmktime-or-mktime/#findComment-946277 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.