PHP Date validation.
PHP Date validation.
Been searching a while but cannot work it out.
My dates are stored in a Msql table as 2017-12-11
So I need to show them in the tables as
11-12-2017 ( ie DD-MM-YYYY)
Also the editor using the date type: 'datetime'
Field::inst( 'start_date' )
->validator( 'Validate::dateFormat', array(
"format" => Format::DATE_ISO_8601,
"message" => "Please enter a date in the format yyyy-mm-dd"
) )
->getFormatter( 'Format::date_sql_to_format', Format::DATE_ISO_8601 )
->setFormatter( 'Format::date_format_to_sql', Format::DATE_ISO_8601 )
)
What is the correct syntax plaes.
Cheers
Steve Warby
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Nearly there guys.
I found this link https://datatables.net/forums/discussion/26818/date-dd-mm-yyyy
client side
server side
This is working and I can change the date manually and save.
But I don't have the 'calendar' popup.
If I change type to datetime I get the calendar but when I update it says the format is in correct.
Which piece of the jigsaw am I not understanding here guys.
Cheers
Steve Warby
Just added the moments.js to my project and when I create a new invoice I can now use:
Cheers
Steve Warby
Thanks for posting back - good to hear you've got it now.
Allan
Still got this
But I don't have the 'calendar' popup.
If I change type to datetime I get the calendar but when I update it says the format is in correct.
Which piece of the jigsaw am I not understanding here guys.
For
d-m-Y
on the server-side try:The Moment documentation for the formatting is available here.
Allan
I have this on the server side.
On the editor I have
So how to I get the popup calendar to set the date to DD-MM-YYYY
Cheers
Steve Warby
Change:
to be:
datetime
usesformat
notdateFormat
.Allan