Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 9 of 9
  1. #1
    Senior Member Seldimi's Avatar
    Join Date
    Dec 2002
    Location
    Kozani, Greece
    Posts
    488
    Member #
    409
    How to get the current date of when a row was added and save the date to a column called 'added' ???
    - Webmaster's Planet . Greek Vortal For Webmasters ...
    - MyPortFolio - View My Creations

  2.  

  3. #2
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    That's not recorded. However to do it in the future, add a column called dateadded (or something similar) and always update rows using the value UNIX_TIMESTAMP() for that column.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  4. #3
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,657
    Member #
    1234
    Liked
    138 times
    Tsk, tsk. We already had this covered in the review ratings system!

    PHP Code:
    $sql  " INSERT INTO review (date_created) ";
    $sql .= " VALUES (NOW()) "
    NOW() will get the current date/time from the server.

    Filburt, is the diff between UNIX_TIMESTAMP() and NOW() that UNIX_TIMESTAMP() is a UNIX only function, where as NOW() is a generic function, avail to the SQL database?
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  5. #4
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    UNIX_TIMESTAMP() returns the date and time in epocs (seconds since Jan 1 1970), a universally-accepted date/time format.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  6. #5
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,657
    Member #
    1234
    Liked
    138 times
    Ok... that's an odd way to do it. Was 1/1/1970 the day they went from 1 digit for the year to 2, or was that 1/1/1980? Either way, happen to know the thought processes behind that decision?
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  7. #6
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Don't know, but that's the way a lot of programs store the date/time including vBulletin. Also makes comparing dates supereasy.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  8. #7
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Another way is using Julian Dates, which i believe counts the number of days and fractions of days since 1/1/1900.

    A Julian Date might look like 32767.9867586, which means 32767 days and 0.9867586 of a day (convert it to hh:mm:ss yourself!) have passed since turn of the century 1900.

    Something else that's becoming popular in floating point dates is the yyyymmdd.hhmmss format, which might look like 20030515.122005, which would translate to 05/15/2003 12:20:05. This format is nice because it's database independant (it's a number, not a date), can be calculated easily with common ANSI-92 arithmetic functions, such as FLOOR (to get the date part only), MODULUS and DIVIDE (to split it up), etc. Also, it sorts chronologically, alphabetically, and numerically in the same order, which is really nifty!

  9. #8
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    The 1970 thing is, I believe, an Internet thing. Since the Internet was invented in 1969, there are no dates that will precede that relevant to web-based applications. That's why it's a TIMESTAMP type, which is exclusively used for recording the date and time of excecution of a transaction.

    For records of dates related to your data, you should use datetimes or julian dates or floating point dates or some other dating method.

  10. #9
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    There could also be the fact that 1969 was the year C was invented. Not sure when DBMS's were invented, but that may affect it too.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:39 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com