Results 1 to 8 of 8

Thread: storing system date in my sql

  1. #1

    storing system date in my sql

    Hello guys, How i can store system date using mysql query
    Code:
    insert into table values('val1',system date here,'value2');
    either I have to use now() function or else.


    or
    using default while creating table
    Code:
    create table abc('col1',system date here,'col2');
    thanks.

  2. #2

    storing system date in my sql

    Hello guys, How i can store system date using mysql query
    Code:
    insert into table values('val1',system date here,'value2');
    either I have to use now() function or else.


    or
    using default while creating table
    Code:
    create table abc('col1',system date here,'col2');
    thanks.

  3. #3
    Senior Member
    Join Date
    Dec 2003
    Location
    LA, CA
    Posts
    292
    Here is a timestamp in php which is day-year-second (day of the year-year-seconds in the day)
    Code:
      $curtime = getdate();
      $curTimeInSec = ((($curtime['hours'] * 60) * 60) + ($curtime['minutes'] * 60) + $curtime['seconds']);
     //create a time stamp for database
          $timearray = array($curtime['yday'], $curtime['year'], $curTimeInSec);
          $dbtimestamp = implode("-", $timearray);
    A mind full of questions has no room for answers

  4. #4
    Senior Member
    Join Date
    Dec 2003
    Location
    LA, CA
    Posts
    292
    Here is a timestamp in php which is day-year-second (day of the year-year-seconds in the day)
    Code:
      $curtime = getdate();
      $curTimeInSec = ((($curtime['hours'] * 60) * 60) + ($curtime['minutes'] * 60) + $curtime['seconds']);
     //create a time stamp for database
          $timearray = array($curtime['yday'], $curtime['year'], $curTimeInSec);
          $dbtimestamp = implode("-", $timearray);
    A mind full of questions has no room for answers

  5. #5
    AO Antique pwaring's Avatar
    Join Date
    Aug 2001
    Posts
    1,409
    If you store the system date as an INT datatype, you can use the UNIX_TIMESTAMP() function of MySQL to get the number of seconds since the epoch.
    Paul Waring - Web site design and development.

  6. #6
    AO Antique pwaring's Avatar
    Join Date
    Aug 2001
    Posts
    1,409
    If you store the system date as an INT datatype, you can use the UNIX_TIMESTAMP() function of MySQL to get the number of seconds since the epoch.
    Paul Waring - Web site design and development.

  7. #7
    Senior Member
    Join Date
    Aug 2001
    Posts
    251
    If you store it as a MySQL timestamp you can convert it to whatever you like with DATE_FORMAT, DATE_ADD, DATE_SUB, UNIX_TIMESTAMP or whatever in the query and hand most of the processing over to a binary application rather than a interpreted script...
    The owl of Minerva spreads its wings only with the falling of dusk. -Hegel

  8. #8
    Senior Member
    Join Date
    Aug 2001
    Posts
    251
    If you store it as a MySQL timestamp you can convert it to whatever you like with DATE_FORMAT, DATE_ADD, DATE_SUB, UNIX_TIMESTAMP or whatever in the query and hand most of the processing over to a binary application rather than a interpreted script...
    The owl of Minerva spreads its wings only with the falling of dusk. -Hegel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •