#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    13
    Rep Power
    0
    I have faced a problem of get the current date and time of server.

    I am going to store the current date and time to one field of mysql database called "joindate(field type:datetime)"

    Can anybody tell me how to get the current date and time and then assign to joindate field, thank you.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Posts
    60
    Rep Power
    15
    This is how I understand your question, get date (php server-side) insert date in DB, and then echo just to test. You can oviously use an UPDATE instead of an INSERT.
    ("UPDATE tablename SET fieldname='$today' where XXX='$xxxx'");

    <?
    /*Prints the Date in MySQL date format per http://php.net/manual/function.date.php3
    */
    $today = date("Y-m-d");
    mysql_connect("localhost", "username", "password");
    mysql_select_db (database);
    mysql_query ("INSERT INTO tablename (fieldname) VALUES ('$today')");
    echo "Date: $today";
    ?>


    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by asktan:
    I have faced a problem of get the current date and time of server.

    I am going to store the current date and time to one field of mysql database called "joindate(field type:datetime)"

    Can anybody tell me how to get the current date and time and then assign to joindate field, thank you.
    [/quote]

  4. #3
  5. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    With any of the mysql date/time datatypes you can simple use the now() function of mysql to insert the current server datetime.

    insert into table (joindate) values (now());

  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    13
    Rep Power
    0
    Thanks for your help

Similar Threads

  1. Time field ? Time AND date ?
    By oobiExtant in forum MySQL Help
    Replies: 7
    Last Post: December 28th, 2004, 10:11 AM
  2. mysql date time stamp and UTF8
    By doomish in forum MySQL Help
    Replies: 0
    Last Post: February 8th, 2004, 09:37 AM
  3. search DB by date range
    By Simm in forum PHP Development
    Replies: 1
    Last Post: February 4th, 2004, 02:35 PM
  4. Replies: 13
    Last Post: February 2nd, 2004, 12:13 PM
  5. Store Date and time in SQL server datetime field
    By vikaspa in forum Visual Basic Programming
    Replies: 1
    Last Post: January 30th, 2004, 06:34 PM

IMN logo majestic logo threadwatch logo seochat tools logo