SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    http://TheICE.co.uk/ The Eerie Network's Avatar
    Join Date
    Apr 2001
    Location
    London in the UK.
    Posts
    293
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how do you store your dates?

    Hi all, quick question, when storing dates in databases for whatever reason (like date of posting messages, etc...) what format do you store them in?

    up until now i've always used the classic yyyy-mm-dd format, but I know there are other options availabe, like the unix time stamp, etc...

    What do you use, and why?
    Daniel Hollands
    New: My Webcam <-- Come and watch me doing what I do
    TheICE.co.uk <-- New sites for the best in UK lifestyle and Competitions.
    The ofDan.Network Forums <-- Come and join in the fun.

  2. #2
    Digital Warrior Renegade's Avatar
    Join Date
    Nov 2000
    Location
    Portland, OR
    Posts
    480
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There are so many different ways to display the traditional yyyy-mm-dd, that I have kind of strayed away from it. Just because, at least for me, it gets slightly confusing when looking at the date for the first time on a new BBS....

    I usually store/display dates in the format of:

    Jan 1, 2001 or January 1, 20001.

    Just my 1.5 cents

  3. #3
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It depends. I always store them in that format, so I can use the built in date functions that MySQL has. If I need in it a unix timestamp, theres even a function to do that UNIX_TIMESTAMP(datefield). So depends on what you are going to do with it. If all you are going to be doing is grabbing the date and diaplying it, I would stick with a traditional datetime type field. In fact I can't find any reason why one should store it in anything other than a datetime field. Except for maybe processing time, not sure if thats even an issue though.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  4. #4
    http://TheICE.co.uk/ The Eerie Network's Avatar
    Join Date
    Apr 2001
    Location
    London in the UK.
    Posts
    293
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, datetime sounds good to me, with luck i'll have people posting information all the time, so displaying the time of the post might be good as well, the only problem is that this now creates LOTS more questions:

    What is the datetime format, and how can I get php to create it (for insertion into mysql)
    how do I then convert the datetime format into a human format (29th June 1979, etc...)

    Thank you.
    Daniel Hollands
    New: My Webcam <-- Come and watch me doing what I do
    TheICE.co.uk <-- New sites for the best in UK lifestyle and Competitions.
    The ofDan.Network Forums <-- Come and join in the fun.

  5. #5
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is where you can get all the info about how to store the date.
    http://www.mysql.com/documentation/m...and_time_types


    Here you can get all the info on how to format it in the qquery and various other functions for comparing dates and getting different info about the date such as weekday, etc....

    http://www.mysql.com/documentation/m...time_functions
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  6. #6
    http://TheICE.co.uk/ The Eerie Network's Avatar
    Join Date
    Apr 2001
    Location
    London in the UK.
    Posts
    293
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you, oh, thank your cat for me too
    Daniel Hollands
    New: My Webcam <-- Come and watch me doing what I do
    TheICE.co.uk <-- New sites for the best in UK lifestyle and Competitions.
    The ofDan.Network Forums <-- Come and join in the fun.


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
  •