I just tried,
date_create_from_format(\'Ym\',\'201302\')
And I guess because it\'s the 29th today, it\'s actually giving me back March 1st.
If
format
does not contain the character!
then portions of the generated time which are not specified informat
will be set to the current system time.If
format
contains the character!
, then portions of the generated time not provided informat
, as well as values to the left-hand side of the!
, will be set to corresponding values from the Unix epoch.The Unix epoch is 1970-01-01 00:00:00 UTC. (DateTime Manual)
So, adding a !
at the beginning of your format
string should fix your problem.