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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

android - How to create dynamically Fragment pager adapter -

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