Which PHP function can return the current date/time?
Best Answer
The time would go by your server time. An easy workaround for this is to manually set the timezone by using date_default_timezone_set before the date() or time() functions are called to.
I'm in Melbourne, Australia so I have something like this:
Timestamps in MySQL are generally used to track changes to records, and are often updated every time the record is changed. If you want to store a specific value you should use a datetime field.
If you meant that you want to decide between using a UNIX timestamp or a native MySQL datetime field, go with the native format. You can do calculations within MySQL that way
("SELECT DATE_ADD(my_datetime, INTERVAL 1 DAY)") and it is simple to change the format of the value to a UNIX timestamp ("SELECT UNIX_TIMESTAMP(my_datetime)") when you query the record if you want to operate on it with PHP.
Best Answer
The time would go by your server time. An easy workaround for this is to manually set the timezone by using
date_default_timezone_set
before thedate()
ortime()
functions are called to.I'm in Melbourne, Australia so I have something like this:
Or another example is LA - US:
You can also see what timezone the server is currently in via:
So something like:
So the short answer for your question would be:
Then all the times would be to the timezone you just set :)