Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Apr 2006
    Posts
    231
    Thanks
    9
    Thanked 1 Time in 1 Post

    MySQL Time Stamp

    Hey all, set up a small time stamp. When I insert results manually I click the little calendar and click current date, it inserts something like 2008-02-19 23:30:15

    How would I be able to insert the same through php?

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    PHP Code:
    $date=gmdate("Y-m-d H:i:s");
    mysql_query("insert into table_name(date) values('$date')") or die(mysql_error()); 
    ??
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder Deacon Frost's Avatar
    Join Date
    Feb 2008
    Location
    Between the Lines
    Posts
    279
    Thanks
    31
    Thanked 4 Times in 4 Posts
    Doesn't this workish?

    PHP Code:
    function formatDate($val)  
      {  
          list(
    $date$time) = explode(" "$val);  
          list(
    $year$month$day) = explode("-"$date);
          list(
    $hour$minute$second) = explode (":"$time);
          return 
    date("l, m.j.y @ H:ia"mktime($hour$minute$second$month$day$year));  
      } 
    mysql:

    PHP Code:
    `datedatetime NOT NULL default '0000-00-00 00:00:00' 

    or some variation of that. then you just select it from the database in an include and add it to it?


  •  

    Posting Permissions

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