hey guys,
i am trying to convert a date from yyyy-mm-dd to dd-mm-yyyy however i dont know how the date function requires a timestamp and i cant get a timestamp form this string...
anyone an idea?
thanks Matthy
hey guys,
i am trying to convert a date from yyyy-mm-dd to dd-mm-yyyy however i dont know how the date function requires a timestamp and i cant get a timestamp form this string...
anyone an idea?
thanks Matthy
$timestamp = strtotime(your date variable);
$new_date = date('d-m-Y', $timestamp);
For more:
http://php.net/manual/en/function.strtotime.php
Or even shorter:
$new_date = date('d-m-Y', strtotime(your date variable));
Use strtotime()
and date()
:
$originalDate = "2010-03-21";
$newDate = date("d-m-Y", strtotime($originalDate));
I think this is function in Php that you need. strtotime. http://php.net/manual/en/function.strtotime.php
How do u need the date in Mysql format?
Also another obscure possibility:
$oldDate = '2010-03-20'
$arr = explode('-', $oldDate);
$newDate = $arr[2].'-'.$arr[1].'-'.$arr[0];
i don't know would use it but still :)
implode('-', array_reverse(explode('-', $date)));
Without date conversion overhead, not sure it'll matter much.