This topic is locked
[SOLVED]

Date format

11/11/2024 6:35:54 AM
PHPRunner General questions
R
Rudy Lambrechts author

I'm a beginner, so this might be a stupid question:
in a table I have a field (date) in a format YYYY-MM-DD. In the designer I can change this to DD-MM-YYYY. So far everything is fine.... but when I create an email (in after add record) the date field returns YYYY-MM-DD in this email. Is there any way to solve this?
Thanks for a solution.

C
copper21 11/11/2024

Rudy,

Just change the format via php. I don't know what your field name is, but just replace it in the below code.

$newdate = date("m/d/Y", strtotime($values['YOURDATEFILED']));

Where you currently have your $values['YOURDATEFILED'] in the email code, replace it with $newdate.

R
Rudy Lambrechts author 11/11/2024

Hey copper21, thanks, I'm really a beginner, sorry. But where do I put the line:
$newdate = date("m/d/Y", strtotime($values['YOURDATEFILED'])); -> the field name is 'Datum'. Sorry for the Dutch language in the code.

$subject="NIEUW SLOT BIJKOMENDE LESUREN INGEBRACHT DOOR KLANT";

$msg.= " "."\r\n";
$msg.= "Er werd een nieuwe tijdslot ingebracht."."\r\n";
$msg.= "Gelieve bijkomende gegevens in te brengen en de klant te bevestigen in de databank."."\r\n";
$msg.= " "."\r\n";
$msg.= " "."\r\n";
$msg.= "Datum : " . $values['Datum'] . " van " . $values['Uur'] . " tot " . $values['tot'] . " uur" . "\r\n";
....

C
copper21 11/11/2024

Try This:

$newdate = date("m/d/Y", strtotime($values['Datum']));

$subject="NIEUW SLOT BIJKOMENDE LESUREN INGEBRACHT DOOR KLANT";

$msg.= " "."\r\n";
$msg.= "Er werd een nieuwe tijdslot ingebracht."."\r\n";
$msg.= "Gelieve bijkomende gegevens in te brengen en de klant te bevestigen in de databank."."\r\n";
$msg.= " "."\r\n";
$msg.= " "."\r\n";
$msg.= "Datum : " . $newdate . " van " . $values['Uur'] . " tot " . $values['tot'] . " uur" . "\r\n";

R
Rudy Lambrechts author 11/11/2024

Thank you very much!