Hi, I'am new to Zope so please excuse me about some stupid questions. How can I format a date field from in a DTML from ZSQL Method e.i.: It shows 2005-01-12 22:49:33:00 but I want to show just 2005-01-12 or change de order of the date :01-12-2005. Thank you for your help. Regards, Zorze
+-------[ Zorze ]---------------------- | Hi, | I'am new to Zope so please excuse me about some stupid questions. | | How can I format a date field from in a DTML from ZSQL Method e.i.: | | It shows 2005-01-12 22:49:33:00 | | but I want to show just 2005-01-12 Try these; <dtml-var "theDate.strftime('%Y-%m-%d')"> or <dtml-var "theDate.strftime('%F')"> (same as above, just shorter). | or change de order of the date | :01-12-2005. <dtml-var "theDate.strftime('%d-%m-%Y')"> -- Andrew Milton akm@theinternet.com.au
+-------[ Zorze ]---------------------- | Thank you Andrew. :-) | | But it give me another an error :-( | | Error Value: You are not allowed to access strftime in this context hrm. What DB are you using? -- Andrew Milton akm@theinternet.com.au
+-------[ Zorze ]---------------------- | Andrew Milton wrote: | | >+-------[ Zorze ]---------------------- | >| Thank you Andrew. :-) | >| | >| But it give me another an error :-( | >| | >| Error Value: You are not allowed to access strftime in this context | > | >hrm. | > | >What DB are you using? | > | > | > | | Firebird It's possible the Firebird adapter sends the dates come back as strings.. try; <dtml-var "ZopeTime(theDate).strftime('%F')"> otherwise I'm out of ideas for now d8) -- Andrew Milton akm@theinternet.com.au
Please post your code and more details about the error so that we can provide greater assistance. ____________________________________________ Peter Millar -----Original Message----- From: zope-bounces@zope.org [mailto:zope-bounces@zope.org] On Behalf Of Zorze Sent: Friday, 14 January 2005 10:18 To: zope@zope.org Subject: Re: [Zope] Format date fields Importance: High Thank you Andrew. :-) But it give me another an error :-( Error Value: You are not allowed to access strftime in this context Regards Andrew Milton wrote: +-------[ Zorze ]---------------------- | Hi, | I'am new to Zope so please excuse me about some stupid questions. | | How can I format a date field from in a DTML from ZSQL Method e.i.: | | It shows 2005-01-12 22:49:33:00 | | but I want to show just 2005-01-12 Try these; <dtml-var "theDate.strftime('%Y-%m-%d')"> or <dtml-var "theDate.strftime('%F')"> (same as above, just shorter). | or change de order of the date | :01-12-2005. <dtml-var "theDate.strftime('%d-%m-%Y')">
<dtml-in ZSQL_log> this is my Firebird connection <tbody> <tr> <table style=" width: 100%; text-align: left;" border="0" cellpadding="0" cellspacing="0"> </td> <td style="width: 200px; vertical-align: center;"><span style="font-family: tahoma;"><br> <small><dtml-var "LG_DATA.strftime('%Y-%m-%d')"></small></td> this is the string (since i'm Portuguese DATA means date) </tr> </tbody> </table> </dtml-in> Peter Millar wrote:
Please post your code and more details about the error so that we can provide greater assistance. ____________________________________________ Peter Millar
-----Original Message----- From: zope-bounces@zope.org [mailto:zope-bounces@zope.org] On Behalf Of Zorze Sent: Friday, 14 January 2005 10:18 To: zope@zope.org Subject: Re: [Zope] Format date fields Importance: High
Thank you Andrew. :-)
But it give me another an error :-(
Error Value: You are not allowed to access strftime in this context
Regards
Andrew Milton wrote: +-------[ Zorze ]---------------------- | Hi, | I'am new to Zope so please excuse me about some stupid questions. | | How can I format a date field from in a DTML from ZSQL Method e.i.: | | It shows 2005-01-12 22:49:33:00 | | but I want to show just 2005-01-12
Try these;
<dtml-var "theDate.strftime('%Y-%m-%d')">
or
<dtml-var "theDate.strftime('%F')"> (same as above, just shorter).
| or change de order of the date | :01-12-2005.
<dtml-var "theDate.strftime('%d-%m-%Y')">
This question has been asked gazillions of times before. If you search the mailing list you can find the answer. If you search google using the key words 'zope format date' you will notice in the results a link to zopelabs. They have this great little cookbook http://www.zopelabs.com/cookbook/990690237 (dtml version) http://www.zopelabs.com/cookbook/1071006893 (zpt version) I have this in the root of my development site so that I can refer to it all the time. HTH ____________________________________________ Peter Millar -----Original Message----- From: zope-bounces@zope.org [mailto:zope-bounces@zope.org] On Behalf Of Zorze Sent: Friday, 14 January 2005 09:56 To: zope@zope.org Subject: [Zope] Format date fields Hi, I'am new to Zope so please excuse me about some stupid questions. How can I format a date field from in a DTML from ZSQL Method e.i.: It shows 2005-01-12 22:49:33:00 but I want to show just 2005-01-12 or change de order of the date :01-12-2005. Thank you for your help. Regards, Zorze _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
participants (3)
-
Andrew Milton -
Peter Millar -
Zorze