UTCDATE missing in hourly forecast

  • 1
  • Problem
  • Updated 4 years ago
UTCDATE always returns empty in hourly forecast (and hourly 10day). Is this expected or is it something with the stations I am selecting? Would be great if this can be fixed, preferably returning an ISO 8601 date with offset from UTC eg 2015-02-18T05:00:00-06:00.

"FCTTIME": {
"hour": "14","hour_padded": "14","min": "00","min_unpadded": "0","sec": "0","year": "2015","mon": "2","mon_padded": "02","mon_abbrev": "Feb","mday": "18","mday_padded": "18","yday": "48","isdst": "0","epoch": "1424268000","pretty": "2:00 PM GMT on February 18, 2015","civil": "2:00 PM","month_name": "February","month_name_abbrev": "Feb","weekday_name": "Wednesday","weekday_name_night": "Wednesday Night","weekday_name_abbrev": "Wed","weekday_name_unlang": "Wednesday","weekday_name_night_unlang": "Wednesday Night","ampm": "PM","tz": "","age": "","UTCDATE": "" }
Photo of Chris C

Chris C

  • 3 Posts
  • 0 Reply Likes

Posted 4 years ago

  • 1
Photo of Tim Roche

Tim Roche, Official Rep

  • 317 Posts
  • 28 Reply Likes
It appears this quirk goes back a couple years, thanks for bringing it to light.  I will put it on the list of improvements to make.  For the interim, epoch is listed, and most languages should be able to convert that to a timestamp easily. 
Photo of Chris C

Chris C

  • 3 Posts
  • 0 Reply Likes
Thank you Tim. I should mention that I am looking to obtain a local timestamp from the json data in a readily accessible format. Momentarily this is not possible without processing of the data. Epoch would be perfect if it had been local to the weather station and not UTC time.
Photo of Tim Roche

Tim Roche, Official Rep

  • 317 Posts
  • 28 Reply Likes
Hi Chris,

Epoch is a universal value.  There is no such thing as a "local" epoch. If your time zone settings are correct any date derived from the epoch should match.

What language are you using?  Maybe I can help you with a code snippet
Photo of Chris C

Chris C

  • 3 Posts
  • 0 Reply Likes
Hi Tim. If I am not mistaken epoch is basically the same as UNIX time and is based on UTC? As I understand it, there is no way at the moment to determine local station time from epoch by means of the hourly forecast data (FCTTIME)?

I have made a workaround in php which is perfectly alright for me for the time being. I'll post it here. Perhaps it can be helpful if someone else has the same problem.

I parse the json object in php, create arrays with the various FCTTIME data needed to make a timestamp and finally concatenate the arrays to a single one containing the timestamp, in my case in the date format Y-m-d H:i:s:

    $mins = array();
    $hours = array();
    $monthday = array();
    $month = array();
    $year = array();
   
    foreach($parsed_json['hourly_forecast'] as $hourly)
    {
            array_push($mins, $hourly['FCTTIME']['min']);
            array_push($hours, $hourly['FCTTIME']['hour_padded']);
            array_push($monthday, $hourly['FCTTIME']['mday_padded']);
            array_push($month, $hourly['FCTTIME']['mon_padded']);
            array_push($year, $hourly['FCTTIME']['year']);
           
    }
   
    $timestamp = array_map(function($a, $b, $c, $d, $e ) { return $a . '-' . $b . '-' . $c . ' ' . $d . ':' . $e . ':00' ;}, $year, $month, $monthday, $hours, $mins);