Tuesday, 15 May 2012

php - Convert mm-dd-yy format to unix time stamp? -



php - Convert mm-dd-yy format to unix time stamp? -

i've spent hours on google , stack exchange. life of me havent found working solution , i'm not sure why.

i need 06-15-14 formatted , unix timestamp. i've tried sorts of things. mktime, strptime, strto...often nil spits out or 12-31-69

i need single digit dates ie - 6-15-14 or 6-5-14

$chance = "come on 06-15-14"; if (preg_match("/[0-9]{1,2}\-[0-9]{1,2}\-[0-9][0-9]/", $chance, $matches)) { echo "match found <br />"; echo $matches[0]; $a = strptime('$matches[0]', '%m-%d-%y'); echo $a; } else { echo "nope"; }

assuming regex correct,

$a = strptime('$matches[0]', '%m-%d-%y');

should be

$a = strptime($matches[0], '%m-%d-%y');

without quotes

php unix timestamp

No comments:

Post a Comment