Reputation: 995
I have the following textfield in my gsp page that does not work as expected:
<g:textField name="startTime"
value="${formatDate(date: occurrenceStart ? new Instant(occurrenceStart).toDate() : eventInstance?.startTime, format: 'dd/MM/yyyy hh:mm a')}"
class="datetime" />
I'm using the source code found here, but each time I select a date and time, the date is shown as MM/dd/yyyy. Where is the place in which I need to change the format?
EDIT: Usually I use Mozilla Firefox to test my project. If I use Google Chrome browser, I have the following formatting date(choosing the 12th of January 2014, 5:00 AM) after the change suggested in Adavis answer:
12/January/20142014 hh:01 a 05:00 am
If I remove the code added, I have the same behaviour described above, with formatting MM/dd/yyyy
Upvotes: 0
Views: 1575
Reputation: 995
Solved with the following code:
function setupDatePickers() {
$.datepicker.setDefaults({
dateFormat: 'dd/mm/yy'
});
$("input.datetime").datetimepicker({
ampm: true,
stepMinute: 15
});
}
Upvotes: 0
Reputation: 3704
In this file: https://github.com/craigburke/google-calendar-grails/blob/master/web-app/js/calendar.js, line 60, in setupDatePickers(), you need to add your date format to the default options of datetimepicker. See below...
function setupDatePickers() {
$("input.datetime").datetimepicker({
ampm: true,
stepMinute: 15,
dateFormat: 'dd/MM/yyyy hh:mm a'
});
}
Upvotes: 1