Advanced Search

Results 1 to 4 of 4

Thread: Storing format of date and time

  1. #1
    Join Date
    Aug 2007
    Location
    Malaysia
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Storing format of date and time

    Hey guys! How can I store the following format of date and time in database?
    Date=Mon 01th Oct
    Time=5 :00pm

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    11,791
    Thanks
    227
    Thanked 657 Times in 645 Posts

    Default

    Don't. Store timestamps, then convert later, using date($format,$stamp);
    Much more versatile and easier to store as well.
    Daniel - Freelance Web Design | <?php?> | <html>| Deutsch | italiano | español | português | català | un peu de français | Ninasoma Kiswahili | 日本語の学生でした。| درست العربية

  3. #3
    Join Date
    Aug 2007
    Location
    Malaysia
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Is it look like that?
    Code:
    `reserve_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
      `reserve_time` timestamp NOT NULL default '0000-00-00 00:00:00',
    How can I convert them to desired format using PHP?

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    11,791
    Thanks
    227
    Thanked 657 Times in 645 Posts

    Default

    Go to php.net. Type "date" in the search field. See formats. Easy.

    You'll be storing a timestamp value into the database, which will be the number of seconds since 1970. It's 1100000000 something right now, or so. use time() to get that. There's also a keyword in mysql, I believe %date% or something, but I forget the details. Look that up.
    Daniel - Freelance Web Design | <?php?> | <html>| Deutsch | italiano | español | português | català | un peu de français | Ninasoma Kiswahili | 日本語の学生でした。| درست العربية

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
  •