How can I store the actual hour and minute,from a mysql table, in variables?I want to store hour and minute like this:
//Connect database
$con = mysql_connect("localhost","root","ufmg3duc");
if (!$con)
die('Could not connect: ' . mysql_error());
//Select database
mysql_select_db("stream_net", $con);
//Read data
$query_month = $_GET['form_month_tend'];
$query_day = $_GET['form_day_tend'];
$query_year = $_GET['form_year_tend'];
if ($query_mes == NULL)
$query_mes = date("m");
if ($query_dia == NULL)
$query_dia = date("d");
if ($query_ano == NULL)
$query_ano = date("Y");
How can i do like i did before but with Hour and MInutes?
storing Time and Dates into an SQL database using php
You should use the datetime datatype
for your requirement. It will store both the date and time from your input field based on your query.
For retrieving the datetime you can use the mysql's date_format()
function or PHP's date()
function. The datetime will always be stored according to the server's time and not on the clients time.
For Hour & Minute
print date('H:i');
$hour = date('H');
$min = date('i');