Similar to the previous post, there exists a function in .js that allows us to get the system settings on the preferred date format. That being said, in this case, it is all via .js and I dont find a similar function in php files. I need to be able to use that function in the php file.
Tips and pointers would be appreciated.
Thanks,
Nick
$aptdatetime=date('D g:i a',strtotime($result["start_datetime"]));
$startdatetime=date('l, F j, Y, g:i a',strtotime($appointment->start_datetime)); var startDatetime = new Date().addMinutes(GlobalVariables.bookAdvanceTimeout);
var endDatetime = new Date().addMinutes(GlobalVariables.bookAdvanceTimeout).addMinutes(serviceDuration);
var dateFormat; switch(GlobalVariables.dateFormat) {
case 'DMY':
dateFormat = 'dd/mm/yy';
break;
case 'MDY':
dateFormat = 'mm/dd/yy';
break;
case 'YMD':
dateFormat = 'yy/mm/dd';
break;
default:
throw new Error('Invalid GlobalVariables.dateFormat value.');
} /**
* Format a given date according to the date format setting.
*
* @param {Date} date The date to be formatted.
* @param {String} dateFormatSetting The setting provided by PHP must be one of
* the "DMY", "MDY" or "YMD".
* @param {Boolean} addHours (optional) Whether to add hours to the result. * @return {String} Returns the formatted date string.
*/
exports.formatDate = function(date, dateFormatSetting, addHours) {
var format, result;
var hours = addHours ? ' HH:mm' : ''; switch(dateFormatSetting) {
case 'DMY':
result = Date.parse(date).toString('dd/MM/yyyy' + hours);
break;
case 'MDY':
result = Date.parse(date).toString('MM/dd/yyyy' + hours);
break;
case 'YMD':
result = Date.parse(date).toString('yyyy/MM/dd' + hours);
break;
default:
throw new Error('Invalid date format setting provided!', dateFormatSetting);
} return result;
};