The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to set correct field in my table for date?

Discussion in 'Database Discussions' started by toplisek, Jan 26, 2011.

  1. toplisek

    toplisek Active Member

    Joined:
    Jan 7, 2010
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    6
    I have set PHP code like.
    PHP:
    date_default_timezone_set ("Europe/Berlin");
    echo 
    time();
    $cur_timestamp date("d-m-Y,H:i:s",time()); //26-01-2011,11:59:31
    echo $cur_timestamp;

    Which type is correct to set date/time with URL like:
    MySQL :: MySQL 5.0 Reference Manual :: 10.3 Date and Time Types

    I have set wthin table:
    Type: TIMESTAMP
    What should be set for other fields?
     
    #1 toplisek, Jan 26, 2011
    Last edited: Jan 26, 2011
  2. coderiser

    coderiser Member

    Joined:
    Jan 31, 2011
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    1
    I tend to store the timestamp as a int and then convert it using php on the display side.

    This can be useful as you can always modify your output and keep your timestamp with your data
     
  3. toplisek

    toplisek Active Member

    Joined:
    Jan 7, 2010
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    6
    Do you change manually local time or server time or you rather change INI specifications that server has local time?
     
  4. coderiser

    coderiser Member

    Joined:
    Jan 31, 2011
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    1
    i found two ways to do this for users in different time zones.

    the 1st is to use a php function to adjust the time to 1 hour ago or 1 day ago as to not confuse the timezone and then simply display the date when posts exceed 1 year or so in time

    the 2nd way is to use javascript to detect the browser set timezone and then pass this as a variable to then auto adjust each output by whatever the timezone session variable is set at.

    I prefer the first way as I think it is more direct and more commonly used
     
Loading...

Share This Page