my current code:
<?php
$timestamp = DateTime::createFromFormat("d.m.Y H:i", $_POST["datetime"]);
echo $timestamp; // works!
?>
Now I’ve a form with two fields: date and time, separated.
<?php
$timestamp = DateTime::createFromFormat("d.m.Y", $_POST["date"]);
echo $timestamp; // works!
$timestamp = DateTime::createFromFormat("H:i", $_POST["time"]);
echo $timestamp; // doesn't work (error below)!
// Edit:
/* Fatal error: Call to a member function getTimestamp() on a non-object in */
?>
I would like to avoid using explode() with mktime(). That feels dirty and I think there could be another, clean way.
How would you create the timestamp from format?
Thanks in advance!
If you want to get the date and time from
$_POST["date"]and$_POST["time"]Use followingIf you want to kow the number of seconds from midnight for that particular time you can however use this,