Question Locked

Reversing date format in php form

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have a simple php contact form with a date picker.
However, the email received from the form reverses the date eg. instead of 20/3/2023 I get 2023/3/20.

My backend form processor file:

//Assign data form array
$date = $_POST['bookdate'];

// Construct email body
$body_message .= 'Preferred Date: ' . $date . "\r\n";

thanks

3 replies

by kees_b edited

And what is your question?

by rob167 edited

Good point! How do I reverse the format to read normally.

by rproffitt edited

From https://stackoverflow.com/questions/13030918/php-reverse-date-function I see there's a PHP function called date_create_from_format which looks fine for this use.

That said, as I worked in the US, Canada and Taiwan I rarely had an issue with what date formats were used. It's a good thing that the year is all 4 digits so that leaves us to figure out what is month and day at times.

This discussion is closed to new replies.