Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2012
    Posts
    142
    Thanks
    39
    Thanked 3 Times in 3 Posts

    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???

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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

  • #3
    Regular Coder
    Join Date
    Aug 2012
    Posts
    142
    Thanks
    39
    Thanked 3 Times in 3 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •