php - Interperet english date string to use with date_format -


in smarty, have date string formatted this: dd/mm/yyyy

when try use date_format gets date wrong.

how can make understand initial string formatted like?

the documentation of date_format smarty variable modifier explains expects value formatted:

this formats date , time given strftime() format. dates can passed smarty unix timestamps, datetime objects, mysql timestamps or string made of month day year, parsable php's strtotime().

the date format using (dd/mm/yyyy) not recognized strtotime() , there reason it: more 1 third of days of year, format cannot told apart mm/dd/yyyy. php developers had choose of these 2 formats recognize , have chosen mm/dd/yyyy (probably because has higher coverage).

a possible solution problem use replace modifier first, change / - or .. both dd-mm-yyyy , dd.mm.yyyy formats valid , recognized strtotime() , not clash other formats.

if current code looks like:

{$date|date_format:'%e %b %y'} 

change to:

{$date|replace:'/':'.'|date_format:'%e %b %y'} 

Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

angular - Copying node modules to wwwroot AspNetCore -