SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: Dates in MySQL

  1. #1
    <? james('rules'); ?>
    Join Date
    Jun 2004
    Location
    Wales, UK
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Dates in MySQL

    Will something like:
    PHP Code:
    $date date(whatever);

    $sql  mysql_query("INSERT INTO blah VALUES '$date'"); 
    Insert the current date of the insert into the database?
    If knowledge is power - Why isn't our army librarians?!
    Statistics show that 63% of all statistics are fake.
    When i was little i broke my neck, and i havent looked back since .
    I completed the internet in 1 week. The end boss was pretty easy though .

  2. #2
    SitePoint Addict pentium10's Avatar
    Join Date
    Apr 2004
    Location
    Transilvania
    Posts
    208
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Probably this will help you!

    Code:
    CREATE TABLE blah (
      id int(11) NOT NULL auto_increment,
      date datetime NOT NULL default '2004-01-01 00:00:00',
      UNIQUE KEY id (id)
    ) TYPE=MyISAM;
    PHP Code:
    mysql_query("INSERT INTO blah VALUES ('', NOW( ) );"); 
    Rype :: book, do, charge, collect,
    track time, track expenses and invoice easily on the go.
    Available on Mac, Win, iPhone, WinMobile.
    http://www.rypenow.com

  3. #3
    <? james('rules'); ?>
    Join Date
    Jun 2004
    Location
    Wales, UK
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dont really wanna re-create the database as i have loads of work to be done..i jsut want to know the correct format to inset a date into a database .
    If knowledge is power - Why isn't our army librarians?!
    Statistics show that 63% of all statistics are fake.
    When i was little i broke my neck, and i havent looked back since .
    I completed the internet in 1 week. The end boss was pretty easy though .

  4. #4
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use timestamp format. Int 15.

  5. #5
    <? james('rules'); ?>
    Join Date
    Jun 2004
    Location
    Wales, UK
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers
    If knowledge is power - Why isn't our army librarians?!
    Statistics show that 63% of all statistics are fake.
    When i was little i broke my neck, and i havent looked back since .
    I completed the internet in 1 week. The end boss was pretty easy though .

  6. #6
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    UK
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 1337-Dev
    Will something like:
    PHP Code:
    $date date(whatever);

    $sql  mysql_query("INSERT INTO blah VALUES '$date'"); 
    Insert the current date of the insert into the database?

    Sure it will, but dependant upon the column type in MySQL.


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
  •