Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-18-2012, 11:57 PM   PM User | #1
rgEffects
New Coder

 
Join Date: Aug 2012
Posts: 76
Thanks: 22
Thanked 0 Times in 0 Posts
rgEffects is an unknown quantity at this point
Local time / GMT display from data field

I have the CRM system that I built from scratch. One of the lines that I need to display is the time of the next appointment. It's a piece of cake to get it done for the users local time zone. I'm using this code:

PHP Code:
date ("@ G:i T     "strtotime ($row_activeContactsRS['nxtTime'])); 
This is displaying like this:

Next Appointment: 10/19/12 at: @ 12:30 PDT (just the bold part)
1PDT[/B] (just the bold part)

What I want to display is :

Next Appointment: 10/19/12 at: @ 12:30 PDT / 19:30 GMT

Any ideas???
rgEffects is offline   Reply With Quote
Old 10-19-2012, 12:15 AM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,653
Thanks: 4
Thanked 2,451 Times in 2,420 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Use the datetime objects. Much easy:
PHP Code:
date_default_timezone_set('UTC');

$dt = new DateTime($row_activeContactRS['nxtTime']);
$tzUTC = new DateTimeZone('UTC');
$tzPDT = new DateTimeZone('PDT');

print 
$dt->format('m/d/y @ G:i T') . PHP_EOL;
$dt->setTimezone($tzUTC);
print 
$dt->format('m/d/y @ G:i T') . PHP_EOL
Fou-Lu is offline   Reply With Quote
Old 10-19-2012, 12:17 PM   PM User | #3
rgEffects
New Coder

 
Join Date: Aug 2012
Posts: 76
Thanks: 22
Thanked 0 Times in 0 Posts
rgEffects is an unknown quantity at this point
That's a good start. However, this just brought up a bigger problem. Users are going to be all over the world so I've got to derive their local time zone, let them enter the time as a local time zone value, store it as GMT. Storing as GMT is the only way that the local time will be correct. I'll have to find a script that will take a local time entry from a text field and convert it to GMT, then read the GMT back as local time for any user in any part of the world.
rgEffects is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:44 PM.


Advertisement
Log in to turn off these ads.