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.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 30 2025 21:44:22
Script start
Timing: Jan 30 2025 21:44:22
Module start 'layout'
Timing: Jan 30 2025 21:44:22
Module start 'content'
Timing: Jan 30 2025 21:44:22
Module end 'content'
Timing: Jan 30 2025 21:44:22
Script end

Main resources:

Total runtime0.0208 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0051 588.1328151.2109
Module start 'layout' 0.00510.0034 739.3438220.6875
Module start 'content' 0.00850.0108 960.03131,001.8203
Module end 'content' 0.01930.0015 1,961.851633.9922
Script end 0.0207  1,995.8438 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002512.2585140.0002
Check MTime0.00104.9254140.0001
Mysql Total
Database connection0.00073.366310.0007
Mysqli_queries0.002813.435330.0009
Looping result0.00000.048210.0000
Template Total0.00104.910.0010
Template load0.00083.866910.0008
Template processing0.00020.996610.0002
Override
Cache load0.00062.682010.0006
General
dbfile0.00021.203280.0000
String conversion0.00000.034440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs