Get time formatted day-month-year in php – PHP snippet

1
742

If you wish to format a date into a different format in PHP is very simple. All you need to do is look bellow. You can use the strtotime function to format a string date into timestamp. After that use the timestamp with date function to get the new format

$oldDate = "2010-03-21"; // year-month-day
$newDate = date("d-m-Y", strtotime($originalDate)); //strtotime convers a string into a timestamp

If you wish to format the current time check this.

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here