Hi everyone,
I’d like to create a variable : “$myDate” of date type with a value attached: “2001-01-31” which is 31th January 2001.
Problem is, I dont know how to do it
Can anyone, please, show me how to assign a date to a date variable in PHP?
If you just want that as a value then that’s a normal string
[php]$myDate = ‘2001-01-31’;[/php]
If you want a proper date object you just do this
[php]$myDate = new \DateTime(‘2001-01-31’);[/php]