I have a UTC time and I need to display it as local time (always
US Eastern time).
I could check to see if we are now in standard or daylight time
and then add the appropriate number of hours, but it seems there
should be an easier way with php automagically doing the proper
conversion.
Any suggestions?
I have a UTC time and I need to display it as local time (always US
Eastern time).
I could check to see if we are now in standard or daylight time and then
add the appropriate number of hours, but it seems there should be an
easier way with php automagically doing the proper conversion.
Any suggestions?
On 3/14/2022 11:10 AM, Lew Pitcher wrote:
On Mon, 14 Mar 2022 10:20:01 -0400, bill wrote:I wasn't clear enough: I have a variable (from an ical string)
I have a UTC time and I need to display it as local time (always
US Eastern time).
I could check to see if we are now in standard or daylight time
and then add the appropriate number of hours, but it seems there
should be an easier way with php automagically doing the proper
conversion.
Any suggestions?
One possibility (which may be overkill for you; you decide) would
be to change the "date.timezone" value in php.ini to name EST5EDT
rather than the default UTC
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = EST5EDT ; override UTC default
From there, you can use the php date functions, and they will
reflect EST5EDT dates and times
HTH
containing the appointment date/time as UTC. In order to display
this I need to convert it to local (12 hr) time.
Thanks bill
On Mon, 14 Mar 2022 10:20:01 -0400, bill wrote:
I have a UTC time and I need to display it as local time (always
US Eastern time).
I could check to see if we are now in standard or daylight time
and then add the appropriate number of hours, but it seems there
should be an easier way with php automagically doing the proper
conversion.
Any suggestions?
One possibility (which may be overkill for you; you decide) would
be to change the "date.timezone" value in php.ini to name EST5EDT
rather than the default UTC
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = EST5EDT ; override UTC default
From there, you can use the php date functions, and they will
reflect EST5EDT dates and times
HTH
On Tue, 15 Mar 2022 12:39:01 -0400, bill wrote:
On 3/14/2022 11:10 AM, Lew Pitcher wrote:
On Mon, 14 Mar 2022 10:20:01 -0400, bill wrote:I wasn't clear enough: I have a variable (from an ical string)
I have a UTC time and I need to display it as local time (always
US Eastern time).
I could check to see if we are now in standard or daylight time
and then add the appropriate number of hours, but it seems there
should be an easier way with php automagically doing the proper
conversion.
Any suggestions?
One possibility (which may be overkill for you; you decide) would
be to change the "date.timezone" value in php.ini to name EST5EDT
rather than the default UTC
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = EST5EDT ; override UTC default
From there, you can use the php date functions, and they will
reflect EST5EDT dates and times
HTH
containing the appointment date/time as UTC. In order to display
this I need to convert it to local (12 hr) time.
Thanks bill
Then, J Aho's advice is what you want. See his response upthread.
On 14/03/2022 15.20, bill wrote:
I have a UTC time and I need to display it as local time
(always US Eastern time).
I could check to see if we are now in standard or daylight time
and then add the appropriate number of hours, but it seems
there should be an easier way with php automagically doing the
proper conversion.
Any suggestions?
something like this?
date_default_timezone_set('UTC');
utc_datetime = '2008-08-03 12:35:23';
$datetime = new DateTime(utc_datetime);
$ny_time = new DateTimeZone('America/New_York'); $datetime->setTimezone($ny_time);
echo $datetime->format('Y-m-d H:i:s');
You have also possibility to use javascript in the UI, then you
could quite simply get to the users local time without having a
config.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 349 |
Nodes: | 16 (2 / 14) |
Uptime: | 120:24:54 |
Calls: | 7,612 |
Files: | 12,789 |
Messages: | 5,684,162 |