I need to revalidate cache if its expired. My cache data looks like this
$cacheData['valid_until'] = "2017-11-23T12:00:00+00:00" //string
I wonder how to properly compare if current dateTime is smaller then $cacheData['valid_until'], while taking into consideration also timezone...
This is my current code
 private function checkCacheValidation($cacheData) {
    $now = (new DateTime());
    $cacheTime = (new DateTime($cacheData['valid_until']));
    if ($now < $cacheTime) {
        die('Cache is valid, no need to request new data');
        return true;
    } else {
        die('cache not valid, get new data');
        return false;
    }
}
Can somebody please check if i'm doing this right way? Do you suggest any other solution?
If you need any additional informations, please let me know and i will provide... Thank you