SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2000
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi. I just started learning PHP and mysql as of today - I came from a Cold Fusion background so I basically got all the basics. (insert, delete, add ,etc.)

    I study any new server-side scripting language by attempting to build a guestbook.

    My question is this:

    How do I make mysql automatically insert a date when the entry is submitted? I use phpmyadmin [from http://www.phpwizard.net] and I'm really stumped on how to do it. Back then, I used access to do everything, and it included the date() feature. I'm assuming mysql has this - particulalry when using phpmyadmin . Help?

    Thanks in advance!

  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)
    It uses CURDATE function,

    select CURDATE();

    for more info about date and time, try here:
    http://www.mysql.com/doc/D/a/Date_an...functions.html
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  3. #3
    SitePoint Addict
    Join Date
    Dec 2000
    Location
    BOSTON MA
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i had almost the same problem 2 days ago.

    you can check out the post here :

    http://www.sitepointforums.com/showt...threadid=17959

    you should really do a search for common topics before posting similar questions.
    you might find a solution quicker than having to wait for people to awnser the question all over again
    . . . chris

  4. #4
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use the mySQL function NOW() to insert the current date/time/timestamp into a mySQL date, time or timestamp field.

    Eg SQL for a table myTable with id(INT), date_added(DATE), blah(TEXT) colums
    Code:
    INSERT INTO myTable SET
       id = 123,
       date_added = NOW(),
       blah = "blah, blah string";


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
  •