fazlurr
6/27/2016 - 3:12 AM

PHP Create Timestamp from String - http://stackoverflow.com/a/6501035/1703124

PHP Create Timestamp from String - http://stackoverflow.com/a/6501035/1703124

<?php
// m/d/y
$timestamp = strtotime('1/1/2011');

// d-m-y
$timestamp = strtotime('1-1-2011');

// Other way
if ( preg_match('/^(?P<day>\d+)[-\/](?P<month>\d+)[-\/](?P<year>\d+)$/', '1/1/2011', $matches) )
{
  $timestamp = mktime(0, 0, 0, ( $matches['month'] - 1 ), $matches['day'], $matches['year']);
}