Hi Everyone
I need help knowing how to calculate midnight “X” days ago in whatever time
zone the user has selected.
- The context of this is creating a report
- An Example: I am want to base the report on records created between
2013-11-01 00:00:00 and 2013-11-07 23:59:59 in the users time
Ron,
You could use the same technique here if you want to do the work in PHP:
=== php code ===
assert( convertToGMT('2013-11-01 00:00:00') == '2013-11-01 04:00:00' );
// EST offset by four hours
assert( convertToGMT('2013-11-07 23:59:59') == '2013-11-08 04:59:59' );
// EDT offset by five
On Nov 10, 2013, at 10:26 AM, Ron Piggott ron.pigg...@actsministries.org
wrote:
I normally use the following code to convert between time zones. But I don’t
know how to calculate what time it is in GMT time zone when it is midnight in
the users time zone X days ago, or midnight on
A suggestion I was given is to use the mySQL CONVERT_TZ command with the
PHP time zone names. But when I do:
SELECT CONVERT_TZ( `journal_entry`.`occurance_date` , 'GMT',
'America/Bahia' ) FROM `journal_entry`
I am receiving NULL as the resulting date. Does mySQL accept PHP time
zone
Typically, yes.
It is possible you don't have the time zone tables populated.
America/Bahia works for me, so I suspect that is the case.
The relevant manual page to load this data (assuming your server is
running in a unix environment) is here: