Re: [Zope] input a date in european style, get it saved as type date (Was: How do I get the first ten characters of a string?)
I like this fmt thing...
I agree...
I tried a few things.
My actual problem now is:
I've got a form, which returns a date string in the form dd.mm.YYYY via REQUEST.
Before this last line I have to change my dd.mm.YYYY into Zope's YYYY/mm/dd. i. e. s. th. like
<dtml-call "REQUEST.set('datum',?????)">
I looked around in the How To's etc. but didn't find anything.
Perhaps you could help me a last time for today.
Here are a couple of things: First, you can tell Zope that a value returned from a form is a specific type; ie: <INPUT TYPE="TEXT" NAME="somedate:date"> <INPUT TYPE="TEXT" NAME="someint:int"> Zope gets the request, and automagically casts somedate into a date object, and someint into an integer. Check out this HowTo regarding Form Variable Types: http://www.zope.org/Members/Zen/howto/FormVariableTypes Second, you can also convert a string into a date object by doing the following: <dtml-call "REQUEST.set('datevalue',_.DateTime(somedate)"> check out the Zope Quick Reference (ZQR) at http://www.zope.org/Members/ZQR for more info on the DateTime() function. One caution, make sure you have validated that the user has inputted a correct date before doing the above. Otherwise you will get error messages. Personally, I use javascript to validate date fields *before* the user submits the form; saves me a lot of headaches. Hope this helps, Andrew Williams _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com
participants (1)
-
Andrew Williams