SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2006
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Retrieve DateTime from MSSQL shows in GMT

    Storing date and time in DATETIME field in MSSQL, but when I'm retrieving it through PHP, it displays in GMT. The server is on Central Time

    Stored in database as: 2010-01-08 16:42:53.000

    Selecting it and converting to unix timestamp by :

    PHP Code:
    $sqry "SELECT orderNo,DATEDIFF(ss,'1970-01-01 00:00:00',orderDate) as orderDate,orderTotal from tbl_Orders where customerID='1'"
    Displaying date as:

    PHP Code:
    $orderDate date("F j, Y  g:i a"$sw['orderDate']); 
    and the end result is:

    January 8, 2010 10:42 am


    I can't figure it out. Any suggestions?

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Subtracting 1/1/1970 in your time zone is not the same as converting to a timestamp, because a UNIX timestamp is the number of seconds since 1/1/1970 GMT. That might account for the offset.

    PHP has strtotime() that can do the conversion for you directly from the date as a string


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
  •