Forums / Developer / manipulating mysql date format

manipulating mysql date format

Author Message

Michael Hall

Wednesday 02 January 2008 6:28:12 pm

Just wondering if there is a built-in template operator or similar that can rewrite a date in YYYY-MM-DD format to DD-MM-YYYY (or similar)? We're using v 3.9.3.

Atle Pedersen

Thursday 03 January 2008 9:37:00 am

As far as I know there are no methods to convert a date input string to a timestamp and then into a date in a different format.

But if your example represents the real problem, you could use string manipulation instead. The explode() operator kan split your string into arrays around the '-'. Then you can rewrite the array in any order you'd like to.

André R.

Thursday 03 January 2008 11:08:30 am

If you need to do more advance stuff with the dates you can use the makedate / maketime template operators to get a unix timestamp out of it.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Piotrek Karaś

Thursday 03 January 2008 11:19:11 am

And at worst you can always try this:

{'2008-11-22'|explode('-')|reverse()|implode('-')}

;)

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

Michael Hall

Thursday 03 January 2008 5:15:59 pm

Thanks for the info. I know this is a trivial task, I thought maybe there was an even easier way.