thellie
Member
Hi,
I've had to adjust my date plugins to local time in order to get the correct date input - I'm in Thailand so its being input -7 hours (ie I input 1 Jan 2018 - date only, no time), and 31 Dec 2017 17.00.00 is added to the dbase.
But I need to create a date comparison field to get "duration of stay", and I'm stuck on the php syntax - it is returning 0 - could someone please show where I'm going wrong?
$enddate = '{vol_appform___enddate}';
$startdate = '{vol_appform___startdate}';
$tz_from = 'Asia/Bangkok';
$tz_to = 'UTC';
$end = new DateTime($enddate, new DateTimeZone($tz_from));
$end->setTimeZone(new DateTimeZone($tz_to));
$start = new DateTime($startdate, new DateTimeZone($tz_from));
$start->setTimeZone(new DateTimeZone($tz_to));
$datediff = ($start - $end);
$diff = round($datediff / 86400);
return $diff;
Thanks
I've had to adjust my date plugins to local time in order to get the correct date input - I'm in Thailand so its being input -7 hours (ie I input 1 Jan 2018 - date only, no time), and 31 Dec 2017 17.00.00 is added to the dbase.
But I need to create a date comparison field to get "duration of stay", and I'm stuck on the php syntax - it is returning 0 - could someone please show where I'm going wrong?
$enddate = '{vol_appform___enddate}';
$startdate = '{vol_appform___startdate}';
$tz_from = 'Asia/Bangkok';
$tz_to = 'UTC';
$end = new DateTime($enddate, new DateTimeZone($tz_from));
$end->setTimeZone(new DateTimeZone($tz_to));
$start = new DateTime($startdate, new DateTimeZone($tz_from));
$start->setTimeZone(new DateTimeZone($tz_to));
$datediff = ($start - $end);
$diff = round($datediff / 86400);
return $diff;
Thanks