Very good, I receive this form of date in a Json: 2017-09-02T00:00:00.000Z
and I would like to be able to treat it to convert it into dd/MM/YYYY
. Does the function exist in php? Thank you
Very good, I receive this form of date in a Json: 2017-09-02T00:00:00.000Z
and I would like to be able to treat it to convert it into dd/MM/YYYY
. Does the function exist in php? Thank you
PHP has the function
date_format
for it, which is an alias of DateTime::formatAs for the format
dd/MM/YYYY
, in PHP it would be expressed like this:"d/m/Y"
, where:d
: Day of the month, 2 digits with leading zerosm
: Numerical representation of a month, with leading zerosY
: A full numeric representation of a year, 4 digitsCode example:
Or... if you want it on one line:
Result:
Or... if you're into Object Oriented Programming (OOP), you create a date object from your string using the DateTime class :
You can use
strtotime
anddate
for what you want.strtotime
convert to unix datedate
gives you the format you want.