Using date and time

Aug 21, 2009 Author: Developer

Fourteen-digit number from the type timestamp in Mysql date and time recorded in the following format the first four number presenting the year, and each paragraph numbers are next month, days, hours minutes and seconds. You may use the function substr () to see the part number, who represent the date and time. As first argument shall be submitted exclusively by the field type timestamp. As the second argument in the form of number to submit the position on the fist symbol, which will be extracted, and the third argument is the length of the symbols string that will be read.

<head><title>Using date and time≤/title>
$conn = mysql_connect ("localhost", "test", "test");
$r = mysql_select_db("clients", $conn );
$sql = "select * from guests where id=1";
$result = mysql_query ($sql, $conn);
# split the date and time in a visual "format
while ($row = mysql_fetch_array ($result))
$time_ = $row ["time_"];
$yea = substr( $time_ , 0, 4 );
$month = substr( $time_ , 4, 2 );
$day = substr( $time_, 6, 2 );
$hour = substr( $time_, 8, 2);
$min = substr( $time_, 10, 2);
$sec = substr( $time_, 12, 2);
$new_time = date("d f y, d h:i a", mktime($hour, $min, $sec, $month, $day, $year));
echo (" date and time of input:".         $new_time);

tags: Using date and time

views 3658
  1. Add New Comment