Welcome Guest, Not a member yet? Register   Sign In
From dd/mm/YYYY

i have string '25/02/2008'
how to make 2008/02/25

the easiest way is
list($day,$month,$year) = explode('/','25/02/2008');
echo $year.'/'.$month.'/'.$day;

[eluser]Bruno Fran├ža[/eluser]

function br2mysql($data) {
    return implode("-",array_reverse(explode("/",$data)));
function mysql2br($data) {
    return implode("/",array_reverse(explode("-",$data)));

Bruno has the easiest way but i suggest you add some form of date validation before you change the format of the string.

I usually use strtotime() in combination with date() for my date manipulation but this particular starting date format doesn't work with strotime. So this has been a really helpful thread. Thanks!

Theme © iAndrew 2016 - Forum software by © MyBB