how to create a specific date format in php -
this question has answer here:
- convert 1 date format in php 12 answers
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:
Comments
Post a Comment