How to get timestamp by Date & Date Format?
$date = "2014-08-21"; $format = "Y-m-d";
$timestamp = get_timestamp ($date,$format);
How to get timestamp by Date & Date Format?
$date = "2014-08-21"; $format = "Y-m-d";
$timestamp = get_timestamp ($date,$format);
As simple as this:
$date = "2014-08-21"; $format = "Y-m-d";
$timestamp = \DateTime::createFromFormat($format, $date)->format('U');
Addition based on the comment below...
For PHP older thatn 5.3 the following code can be used:
$timestamp = strtotime($date);
In this case you should make sure that your date format is one of the supported formats. In your example it is "Year, month and day with dashes" so it should work.