SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Addict isuru's Avatar
    Join Date
    Nov 2000
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I recently found out that there are two ways to store dates in a database:
    1) You can convert the date now and store it in a date field and then pull that out when you need it

    OR

    2) You can store the integer produced by the time() function in an integer field and then pull it out when you need it and then format it using the date() function

    Are both methods the same? is one better in some way? is one of the methods faster than the other?

  2. #2
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I always use Epoch time() since it's always easier for me to process it. I don't see of much a difference though, both to store date, but if you do much stuff with PHP, I think use time() will be more helpful.
    And I don't see what the "date" type in MySQL could do anything special?!
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  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)
    The only benefit to the date field in MySQl is there are built in functions in MySQL that you can use right in your query to calculate dates and format them right in the sql statement
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  4. #4
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh yeah, and DATE in MySQL is human-readable while time() return a string of 9 numbers! Just curious when will it jump to 10 numbers it's 97xxxxxxx something now!
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy


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
  •