wobbie Posted May 9, 2007 Posted May 9, 2007 I'm just starting out with xslt and I have a problem with the formatting of dates. I have a database where the date is formatted DD/MM/YYYY When I look at the records in the browser, all the dates are formatted MM/DD/YYYY I've tried to get it work with fmxslt:convert datetime... but I'm stuck.....so what I want is to have an input field with the date in the format DD/MM/YYYY as it is in the database Here's the code of my input field Can anyone help me out?
Mikhail Edoshin Posted May 10, 2007 Posted May 10, 2007 (edited) Check the date formatting functions. Page 72-74 of Custom Web Publishing Guide. Basically you need the fmxslt:convert_datetime() function: fmxslt:convert_datetime(oldFormat, newFormat, date) All parameters are strings, the date parameter is the date field and the oldFormat parameter is the default date format, which is specified somewhere in the XML tree or can probably be read using other functions described on these pages. Edited May 10, 2007 by Guest
wobbie Posted May 11, 2007 Author Posted May 11, 2007 Hello I've found this function but I can't seem to get it work with the input field. If I use the regular code everything works fine but I have no idea how to use this in combination with the input field... If you could help me out....
Martin Brändle Posted May 13, 2007 Posted May 13, 2007 You will always have the problem with date input fields that users can interchange month and day, so you should give them a hint how to enter a date. I will write a solution later, GTG now.
Martin Brändle Posted May 13, 2007 Posted May 13, 2007 There are two things to distinguish - date format as it is displayed and set for the field in the database, and date format used in the web display. The latter is always stored in the fmresultset tree in /fmrs:fmresultset/fmrs:datasource/@date-format. This is normally the default, MM/dd/yyyy . If you don't transform it, it will be displayed like this. This is also the only format the database accepts when submitting a date by way of the web browser. So in your case you don't need to do anything, just submit the record. In the database, the internal formatter set for the field will display the submitted date the way you wish. If you transform the web-date to another format than given by /fmrs:fmresultset/fmrs:datasource/@date-format by way of fmxslt:convert_datetime, and use this transformed date in the input field, the dates stored in the database will be wrong. If you really want to do that, then there is only the way by using an intermediate submission step: - submit to a text field an intermediate database/table - read value of this text field - convert to correct date format - /fmrs:fmresultset/fmrs:datasource/@date-format - with fmxslt:convert_datetime() - resubmit converted date to target database/table with the XSLT document() function
Recommended Posts
This topic is 6404 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now