I'm currently working with weather data feeds to assemble some accurate data. This particular feed is being pulled from Norway and has a format of 2012-01-13T19:00:00. The "T" is what throws me off.
Does anyone know if PHP will recognize this format and/or provide a function to parse this particular timestamp?
I would have thought a combo of strtotime() and date(), but apparently it only accepts English formats? I would prefer to avoid doing a regex to strip out the T but if it's necessary I'll work with it.
Many thanks for the help.
Yes, PHP will recognize it, because that's a standardized format.
$timestamp = strtotime('2012-01-13T19:00:00');
function isValidDateTime($dateTime)
{
if (preg_match("/^(\d{4})-(\d{2})-(\d{2}) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/", $dateTime, $matches)) {
print_r($matches);
if (checkdate($matches[2], $matches[3], $matches[1])) {
return true;
}
}
return false;
}