Forum Moderators: coopster
now i want to use php script to display it as YYYY-MM-DD..i have tried with below script but i get the output as 1970-01-01..this is my script:
$date2=date("Y-m-d", mktime(0,0,0,date("Y",$datetime),date("m",$datetime),date("d",$datetime)));
echo"$date2";
i want it get my output as 2004-07-05, any idea? any example?
There are a couple of ways of doing this:
1. Use strtotime():
$date_query_result = "2004-07-05 11:05:08";
$date2 = date("Y-m-d", strtotime($date_query_result));
echo $date2;
date() expects a timestamp as it's second arugment.
2. use explode():
$date_query_result = "2004-07-05 11:05:08";
$date2 = explode(" ", $date_query_result);
echo $date2[0];