98
Views
5
Comments
Dateformat
Question
I changed the dateformat to of my datepicker to "%d-%m-%Y".
When I click the 'GetAvailableRooms button I get the message 'Date Expected'.

When I retrieve a date from the database it is displayed as "%Y-%d-%m"
Does this mean that the dateformat in the datepicker is not just a display format?

How do I use this properly? That is, display the picked or retrieved date in the specified format but submit it as, well, as a date. 

2021-04-17 17-51-40
George Jeffcock
the work around would be to change the validation to Server side, then check if 'CheckInDate' failed basic validation...if so reformat the date to match the environment settings format, retest is it valid. If valid update Booking_CheckInDate.Valid flag and booking form valid flag.......

The question would be why do you want these dates entered in a different format than the environment? Change the environment settings?




2021-04-17 17-51-40
George Jeffcock
If there is a true business case to have this date formatted differently from the environment setting I guess you could also use JavaScript to reformat the date on submit on the client side, a good chance for you to test the bespoke capabilities of the platform. I would also aim to keep the server side logic as standard as possible, so doing this little bit of javascript formatting on the client side would seem the cleanest solution as this limits the impact to just client side.
UserImage.jpg
Laurens van Rijsbergen
All very well for this partuclar case,but what if there are endusers in different countries with a different datetime format?
I think i need to write a c# module that determines the culture and adapts the datetime format accordingly. 


2021-04-17 17-51-40
George Jeffcock
Some interesting links about your issue..and so far I can't find a way to change the date format at runtime for the application just by espaces. one to one for countries and espaces? But I can understand that becuase of translations.

Some interesting links about your issue:

About DateFormat property on RichWidgets\Input_Calendar
Configure the Dates Display Format
Customer date formats for input fields



Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.