[wd_asp elements=’search’ ratio=’100%’ id=1]

Create new time date format – PHP

10th September 2015

Php - Dates & Time

php codehaven

$old_date = date('y-m-d-h-i-s');
$new_date = date('Y-m-d H:i:s', strtotime($old_date));

Change how it looks


$timewanted = '14:00:30';
OUTPUT 14:00
echo $new_date = date('H:i', strtotime($timewanted));

and convert date format

$dob = "1940-01-02";
echo $dob = date("d-m-Y", strtotime($dob));

OUTPUT 02-01-1940