Forums / General / Trying to get correct datetime format

Trying to get correct datetime format

Author Message

Massimiliano Bariola

Monday 20 June 2005 10:36:22 am

hi,

I am trying to get datetime fields correctly formatted as epr my regional settings (Italy, set as ita-IT in the Locale parameter of site.ini.append.php)

unfortunately, this line

{attribute_view_gui attribute=$race.object.data_map.data_inizio}

gives me a result like 2005.07.11 instead of 11/07/2005

while the following

{$race.object.data_map.data_inizio.content|l10n('shortdate')}

outputs 01/01/1970 .

Any help?

regards,

MB

Vjeran Vlahovic

Monday 20 June 2005 12:22:29 pm

Hi Massimiliano,

Try this:

{$race.object.data_map.data_inizio.data_int|l10n(shortdate)}

http://www.netgen.hr/eng

Daniel Beyer

Monday 20 June 2005 3:39:04 pm

Take a look to:
http://www.ez.no/ez_publish/documentation/development/libraries/ez_template/operators/miscellaneous

For $timestamp|l10n('shortdate') you can use this, too (instead of 'shortdate'):

-datetime
-shortdatetime
-time
-shorttime
-date
-shortdate

The format of those is defined in your locale config in file /share/local/YOUR-LOCALE.ini.

The reason, why {attribute_view_gui attribute=$race.object.data_map.data_inizio} gives an other output is, that attribute_view_gui uses a template to display results. Take a look to the following templates in folder /design/standard/templates/content/datatype/view:
-ezdate.tpl
-ezdatetime.tpl
-eztime.tpl

Daniel Beyer
_________________________________
YMC AG
Kreuzlingen, Switzerland
web: www.ymc.ch
____________________________________

Massimiliano Bariola

Tuesday 21 June 2005 1:20:47 am

Vjeran, Daniel,

I got it sorted thanks to your advice. It's strange, though, that even after setting the locale in my site.ini.append.php, the default output of a locale-dependent datum is not formatted according to the default chosen locale format.

Thanks again!

Daniel Beyer

Tuesday 21 June 2005 4:34:21 am

Hi,

try to add this to /settings/override/site.ini.append.php

[RegionalSettings]
# The primary language for your site
Locale=ita-IT

After that you should get the following formats:
-datetime: Martedì, 21 Giugno 2005 13:39:33
-shortdatetime: 21/06/2005 13:39
-time: 13:39:33
-shorttime: 13:39
-date: Martedì, 21 Giugno 2005
-shortdate: 21/06/2005

Assuming you use the following template-code:

-datetime: {currentdate()|l10n('datetime')} <br />
-shortdatetime: {currentdate()|l10n('shortdatetime')} <br />
-time: {currentdate()|l10n('time')} <br />
-shorttime: {currentdate()|l10n('shorttime')} <br />
-date: {currentdate()|l10n('date')} <br />
-shortdate: {currentdate()|l10n('shortdate')}

If it take long to load your page after you add the code to /settings/override/site.ini.append.php it's because the translations has to be generated. This is a sing that you did not set "Locale=ita-IT" anytime before (since you cleaned you cash last).

Daniel Beyer
_________________________________
YMC AG
Kreuzlingen, Switzerland
web: www.ymc.ch
____________________________________

Massimiliano Bariola

Tuesday 21 June 2005 5:34:49 am

Hi Daniel,

I had indeed put the configuration line you suggested in my site.ini.append.php, so I was puzzled to see that eZpublish is not really using that value to implicitly format the relevant datatypes - instead, I must explicitly call the i10n(...) operator.

Daniel Beyer

Tuesday 21 June 2005 7:02:48 am

That's true. You have to call the i10n operator if you want something formated for your locale. It's the same with eg. currencies, too. If you don't want to call the operator you can either change or override the accordant template in your design or formate the date by hand with datetime(custom,"FORMATOPTIONS"). For example:

{$currentdate()|datetime(custom,"%m %y")}

Which will result in:
06 05

You can use for "FORMATOPTIONS" the options mentioned in the date function of php:
http://www.php.net/date

Daniel Beyer
_________________________________
YMC AG
Kreuzlingen, Switzerland
web: www.ymc.ch
____________________________________

Massimiliano Bariola

Tuesday 21 June 2005 7:49:47 am

Well, as long as I know I have to remember to put the i10n I'll be fine ... just wondering whether I was missing something ...

Thanks!

eZ debug

Timing: Jan 19 2025 12:35:01
Script start
Timing: Jan 19 2025 12:35:01
Module start 'content'
Timing: Jan 19 2025 12:35:02
Module end 'content'
Timing: Jan 19 2025 12:35:02
Script end

Main resources:

Total runtime1.2586 sec
Peak memory usage4,096.0000 KB
Database Queries211

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0071 588.9688180.8359
Module start 'content' 0.00711.1261 769.8047661.3438
Module end 'content' 1.13320.1253 1,431.1484345.0625
Script end 1.2585  1,776.2109 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00490.3905210.0002
Check MTime0.00190.1545210.0001
Mysql Total
Database connection0.00050.043310.0005
Mysqli_queries1.153391.63702110.0055
Looping result0.00230.18482090.0000
Template Total1.224497.320.6122
Template load0.00310.247620.0016
Template processing1.221297.032520.6106
Template load and register function0.00010.006610.0001
states
state_id_array0.00150.119710.0015
state_identifier_array0.00080.060420.0004
Override
Cache load0.00300.2368720.0000
Sytem overhead
Fetch class attribute can translate value0.00140.109240.0003
Fetch class attribute name0.00190.1483110.0002
XML
Image XML parsing0.00380.303140.0010
class_abstraction
Instantiating content class attribute0.00010.0051160.0000
General
dbfile0.00820.6507410.0002
String conversion0.00000.000530.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
8content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
8content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
14content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 41
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs