Extra flight fields, improved data import function
This commit is contained in:
@@ -242,6 +242,37 @@ function _datetime_to_ts($date) {
|
||||
//return mktime($date_split[5], $date_split[6], 0, $date_split[2], $date_split[3], $date_split[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to turn a loosely formatted date into a timestamp
|
||||
*
|
||||
* @param $date in format DD/MM/YYYY HH:mm
|
||||
* @return unix timestamp formatted for current time zone
|
||||
*/
|
||||
function _datetime_to_ts_nonstrict($date) {
|
||||
$pattern = '/^(\d{1,2})\/(\d{1,2})\/(\d{4})(\s+(\d{1,2})\:(\d{1,2}))?/';
|
||||
|
||||
//check for a match
|
||||
if (preg_match($pattern, $date, $matches))
|
||||
{
|
||||
$date_split = $matches;
|
||||
}
|
||||
//return zero now if no matches
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
date_default_timezone_set(TIMEZONE);
|
||||
$tz = new DateTimeZone(TIMEZONE);
|
||||
|
||||
$gmt_ts = mktime($date_split[5], $date_split[6], 0, $date_split[2], $date_split[1], $date_split[3]);
|
||||
$ts = new DateTime("@$gmt_ts");
|
||||
$ts->setTimezone($tz);
|
||||
|
||||
return $ts->format("U");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to split date into array
|
||||
*
|
||||
|
Reference in New Issue
Block a user