SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jul 2001
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySQl Timestamp... that works

    I apologize beforehand if I am near incomprehensible, it's 4 am and I have been staring at code for 5 hours now. What I need is an automatic timestamp added by mysql that returns the date like: 04.08.02 and only the date, not the time.

    here is my very unfinished query, in it's PHP state:

    PHP Code:
    $sql "INSERT INTO news SET
           subject = '
    $subject',
           body = '
    $body',
         author = '
    $author',
             date = DATE_FORMAT(CURDATE(), %m.%d.%Y)"

    I know it is wrong. Please set me straight.

    I'm going to go pass out now. Thanks for the help.

  2. #2
    SitePoint Member
    Join Date
    Feb 2002
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    alternative..

    hey, i've been very frustrated with the whole MySQL date thing, so i just use the php date function. it's a lot more simple. just create a hidden field with the value of the date() function

    <input type="hidden" value="<?echo date(H.':'.i.':'.S);?>" name="date" />

    and then just insert that variable into your DB. liek so:

    $sql = "insert into table_name (date) values(\"$date\") ";

    hope this is of help. peace..

  3. #3
    SitePoint Evangelist CyberFuture's Avatar
    Join Date
    May 2001
    Location
    San Diego, CA
    Posts
    434
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I haven't tried this with just the date, but I think it should work.
    PHP Code:
    date NOW()"; 


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
  •