Monday, May 16, 2016

Date Format Function Change Date Format In PHP

Many People have problem in converting between various date formats in PHP.So I have discussed some basic solutions to some common date related problems in this post.

Converting Date Format From dd-mm-yyyy to yyyy-mm-dd
echo date("Y-m-d",strtotime($time));
Converting Date Format From yyyy-mm-dd to dd-mm-yyyy
$new_date = date(d-m-Y, strtotime(your date variable));
Changing Date Format From Full Month Name
date("Y-m-d",strtotime("Your Date Variable"));
 For Example,
date("Y-m-d",strtotime("15 November, 2012"));
 Returns 2012-11-15.

Hope this solves some of yours Date related problems in PHP.

If you like this php script, you can Subscribe below to receive all our future updates directly in your email for free.

Cheers.
Have A Great Day!