how to create a specific date format in php -


this question has answer here:

we have current date format 02-05-15 , output want 02/05/2015 in php.

use datetime

$mydatetime = datetime::createfromformat('d-m-y', "02-05-15"); echo  $mydatetime->format('d/m/y'); // output : 02/05/2015 

note:

you may want set default timezone before using datetime, i.e.:

date_default_timezone_set("europe/lisbon"); 

for date_and_time , other php best practices visit:

http://www.phptherightway.com/#date_and_time


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -