SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist
    Join Date
    Mar 2011
    Location
    Bellingham, WA
    Posts
    450
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Converting "America/Los Angeles" to PST

    Hi!

    I'm not sure that this question is appropriate for the forum, so apologies in advance, but I was wondering if there's a publicly available database that can convert php's timezones to those that we use in everyday speech. For example, php's timezone of "America/Los Angeles" would match up to PST. (Pacific Standard Time).

    Thank you,

    Eric

  2. #2
    SitePoint Evangelist
    Join Date
    Oct 2005
    Location
    Michigan, USA
    Posts
    434
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I would think there is somewhere but I don't know of it. Here's one way to get it done.

    PHP Code:
    $tz date_default_timezone_get();
    date_default_timezone_set'America/Los_Angeles' );
    $shorthand date'T' );
    date_default_timezone_set$tz ); 
    - Robert

  3. #3
    SitePoint Evangelist
    Join Date
    Mar 2011
    Location
    Bellingham, WA
    Posts
    450
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Even better! Thank you for your response.

    -Eric

  4. #4
    @php.net Salathe's Avatar
    Join Date
    Dec 2004
    Location
    Edinburgh
    Posts
    1,397
    Mentioned
    65 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by QMonkey View Post
    I would think there is somewhere but I don't know of it. Here's one way to get it done.

    PHP Code:
    $tz date_default_timezone_get();
    date_default_timezone_set'America/Los_Angeles' );
    $shorthand date'T' );
    date_default_timezone_set$tz ); 
    And here are two more, doing the same thing in different styles, that don't affect the script-wide timezone setting:

    Code php:
    echo date_format(date_create('now', timezone_open('America/Los_Angeles')), 'T');

    Code php:
    $now = new DateTime('now', new DateTimeZone('America/Los_Angeles'));
    echo $now->format('T');
    Salathe
    Software Developer and PHP Manual Author.

  5. #5
    SitePoint Evangelist
    Join Date
    Mar 2011
    Location
    Bellingham, WA
    Posts
    450
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Even cooler! Thanks to you both.

    -Eric


Bookmarks

Posting Permissions

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