For eg, I have this code for my PHP calendar events application.
/**MySQL code to get the date*/
$get_Eventbyid_sql = "select event_title, event_shortdesc, event_start as fmt_date from
calendar_events where id=".$_GET['id'].";";
where event_start is my date/time fields.
So now I want to display its hour and minute components on the form.
for eg if event_start was 2012-03-25 02:30:00
Then I oughta get 02 and 30 by using the following code below.
echo "<input type=text name=event_time_hh value='".date("h",$fmt_date)."'>";
echo "<input type=text name=event_time_mm value='".date("i",$fmt_date)."'>";
But the results were different.
date(“h”, $fmt_date) returns 12:
date(“i”, $fmt_date) returns 33;
Where do these numbers come from? Where did I go so wrong?
The second argument to
dateneeds to be a numeric timestamp, not a date string. Use:Also, take care of that SQL INJECTION!