Date datatype formating

Author Message

mario feichtinger

Wednesday 21 May 2003 2:20:32 am

>Re: Date datatype formating
>as i unserstand from ur 1st post, that date format what ur have is >2002.12.20, then u will need to convert it to timestamp to use this option >in the template language !

you mean i have to change the datatype of the date attribute in the database? my date attribute has the datatype date field.
what is correctly the right datatype? is this time field or date time field?

>try this
>{$content_version.data_map.published|datetime(custom,"%l %d %F %Y")}
>if u got as u want, then ok, if not then u need to translate the date in the >local files/ files maybe !

which files do you mean?

Selmah Maxim

Wednesday 21 May 2003 5:18:50 am

Hi ... (agian) :)

listen, you have add to your class date datatype, to make the user insert the date ,am i right ?

if yes, then you cann`t format the date, coz is insert it to the databese with another format (2002.12.20), for formating the date as you need, the date must be timestamp, it`s look like this (15689186), it`s the number of secends, if u count lets say 6 month is 7776000 secend as i think, so in ur case u need to reformat it and then send it back to datatime operator, u will need to write some php code for that, the function for converting ur date is easy:

Function DateToTimonthtamp($date)
{
$date=str_replace('.','',$date);

$year = substr( $date, 0, 4 ) ;
$month = substr( $date, 4, 2 ) ;
$day = substr( $date, 6, 2 ) ;
$hours = substr( $date, 8, 2 ) ;

$unixTime = strtotime( "$year-$month-$day" ) ;
return $unixTime ;
}
echo DateToTimonthtamp("2002.12.20");

but how to use it in ez32 code is hard !

what ever, ur date look nice, keep it at is it :)

mario feichtinger

Thursday 22 May 2003 12:48:28 am

hi,
i have changed my datatype from date to datetime and to time.
in the template i tried these
{attribute_view_gui attribute=$content_version.data_map.dt|datetime(custom,"%d %m %Y")}{attribute_view_gui attribute=$content_version.data_map.t|datetime(custom,"%d %m %Y")}.
but with no success.
for what is the ez3 function datetime?
grrrhh

Bruce Morrison

Friday 23 May 2003 6:53:44 pm

Hi Mario

Try
{$content_version.data_map.published.data_int|datetime(custom,"%d %m %Y")}

{attribute_view_gui attribute=$content_version.data_map.published|datetime(custom,"%d %m %Y")}

doesn't work as the attribute_view_gui returns the formated datetime and the datetime function expects an interger as a parameter.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

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