1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Timestamp problem

Discussion in 'PHP' started by Weirfire, Sep 29, 2005.

  1. #1
    I have 6 PHP variables $sec, $minute, $hour, $day, $month and $year. Don't ask me why, I just do :)

    I use $date=mktime($hour,$minute,$sec,$month,$day,$year); to change it into the format I need for a timestamp value for the MySQL database.

    I then try to insert the date value using

    mysql_query("INSERT INTO table (date) VALUES (TIMESTAMP('$date'))"); which gives the value in the table the timestamp of the current date rather than the edited date above.

    Just wondering if anyone has an idea of what I'm doing wrong here and if they know how you would enter the editted value of the timestamp into the database?
     
    Weirfire, Sep 29, 2005 IP
  2. palespyder

    palespyder Psycho Ninja

    Messages:
    1,254
    Likes Received:
    98
    Best Answers:
    0
    Trophy Points:
    168
    #2
    Sent a solution via PM ;)
     
    palespyder, Sep 29, 2005 IP
  3. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #3
    Anyone that needs the solution it is;

    change the date to

    $date = date("Y-m-d h:i:s", mktime($hour,$minute,$sec,$month,$day,$year));

    Thanks palespyder :)
     
    Weirfire, Sep 29, 2005 IP