SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: timezone...

  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 1999
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would like to change the timezone in PHP tempoarily from EST to PST. How do I do this?

    Also, could anyone tell me how to change a date format in timestamp(14) to something readable like this January 30th, 2001. I know how to do this in a mySQL query, but not in plain PHP.

    Your help is much appreciated.
    Ian Chiu
    Editor in Chief
    http://www.usbworkshop.com/

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1)

    To change time zones from EST to PST we need to subtract 3 hours

    $pdate = date("g:i:s A", mktime(date("G") - 3, date("i"), date("s"), date("m"), date("d"), date("Y")));

    print $pdate;


    2)
    First use UNIX_TIMESTAMP(datefield) in your select field so you have a unix time stamp to work with. Assign it to a var lets say $utime

    print DATE("F jS, Y", $utime);

    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 1999
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks, but the 2nd one doesn't work.

    First use UNIX_TIMESTAMP(datefield) in your select field so you have a unix time stamp to work with. Assign it to a var lets say $utime

    print DATE("F jS, Y", $utime);

    Here's my code

    <? print DATE("F j, Y", $row[updated]); ?>

    and that's the output page...
    http://www.usbworkshop.com/hardware/rvw.php3?id=569

    "...Full review January 18, 2038..."




    Ian Chiu
    Editor in Chief
    http://www.usbworkshop.com/

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What does the query look like? Why are you against doing it in the query anyways?

    SELECT UNIX_TIMESTAMP(update) as utime from tablename;

    or SELECT DATE_FORMAT(updated, '%Y %m %d') as utime from tablename
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    SitePoint Enthusiast
    Join Date
    Dec 1999
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I need to change a lot codes just to do this...

    What's wrong with this anyway?

    Thanks.
    Ian Chiu
    Editor in Chief
    http://www.usbworkshop.com/

  6. #6
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I guess what it boils down to you are not explaining yourself very well. Your first post says

    Also, could anyone tell me how to change a date format in timestamp(14) to something readable like this January 30th, 2001. I know how to do this in a mySQL query, but not in plain PHP.
    Why do you not want to use Mysql date functions to make the display? It would be extra processor speed to get the date in its orginal format and use PHP to break it up and display it using PHP DATE() functions. You can either do it in the query(preferred way) or convert the timestamp into unixtime in the query then use php DATE() function to change the unixtime value from the query into a display format.

    Does that clear it up for you? Please clarify and we can help you much better
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


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
  •