How to format DatePicker date to dd/mm/yyyy so that it displays correctly in the form field and is validated correctly?
I understand that MySQL stores date in Y-m-d H:i:s format. However, I want to generate dates based on dd/mm/yyyy and display in this format in the form field once the date is picked (and validated as dd/mm/yyyy). Unfortunately, it doesn't work. I tried all the methods described in the other threads but still can't get it work. I experimented with different permutations and ended up getting invalid format warning, incorrect format or 1/1/1970.
Can you advise what I should do? I have run out of idea how to make this work. Here are the codes in questioned:
DatePicker...
$(function(){
$('#session_date_start').datepicker({
changeMonth: true,
changeYear: true,
dateformat: "dd/mm/yy",
onClose: closeDatePicker_session_date_start
});
Form Field...
<input id="session_date_start" name="session_date_start" type="text" value="<?php echo((isset($_GET["invalid"])?ValidatedField("sessionupdate","session_date_start"):"".(($row_WADAsession["session_date_start"])?date("d/m/Y",strtotime($row_WADAsession["session_date_start"])):"")."")); ?>" class="formTextfield_Medium" tabindex="4" onBlur="hideServerError('session_date_start_ServerError');">
});
Spry Validation...
var session_date_start_Spry = new Spry.Widget.ValidationTextField("session_date_start_Spry", "date",{ format:'dd/mm/yyyy' , validateOn:["blur"]});
Attached is the php file. The problematic field is: session_date_start. Once this issue is solved, I will replicate the correct formatting to the other date fields.