Use PHP to convert a Time & date

Ask your questions here.
Post Reply
StuartB_75
Posts: 227
Joined: 24 Sep 2018, 23:22
Name: Stuart B
Location: Manchester UK

Use PHP to convert a Time & date

Post by StuartB_75 »

Hi, good morning,
I've a spreadsheet of information to import which includes date and time in the format of DD/MM/YYYY and I'd like to correct them after import to be YY-MM-DD. There are too many to manually have to 'clean' in the spreadsheet before import.
I thought I could do it through PHP within my app, using the imported date in field [820] where the date imports to. I set up a PHP field and added the following:

$orgDate = [820]; //get the imprted dated
$date = str_replace('/','-',$orgDate);//swap the slash for a dash
$newDate = date("yy-MM-dd",strtotime($date));//create new date

I've ticked to create it dynamically, but I don't get an entry in the field. I wonder if anyone can help?

Thanks in advance
filip
Posts: 36
Joined: 24 Dec 2019, 11:40
Name: Flilip Milašinović
Location: Serbia, Zemun

Re: Use PHP to convert a Time & date

Post by filip »

Dates do not work like that, no strings, no slashes and dashes... just UNIX time (number of seconds since 1970).
So, to display dates in adequate format in application change date format of Rukovoditel application.

Configuration -> Application -> Date Format

To change date format in exact Date Field, change: Settings -> Date Format

Regards,
Filip
Post Reply