diff --git a/controllers/controllers.php b/controllers/controllers.php index 5f82ea6..f2056ab 100644 --- a/controllers/controllers.php +++ b/controllers/controllers.php @@ -180,7 +180,7 @@ $app->post('/post', function() use($app) { $entry->tz_offset = tz_offset_to_seconds($params['note_tzoffset']); $published = $date_string; } else { - // Pebble doesn't send the date + // Pebble doesn't send the date/time/timezone $entry->published = date('Y-m-d H:i:s'); $published = date('c'); // for the micropub post if($location && ($timezone=get_timezone($location['latitude'], $location['longitude']))) { diff --git a/lib/helpers.php b/lib/helpers.php index f47f016..ef446f3 100644 --- a/lib/helpers.php +++ b/lib/helpers.php @@ -314,7 +314,7 @@ function query_user_frequent_options($type, $user_id) { function query_last_eaten($user_id, $type, $content) { $lastQ = ORM::for_table('entries')->raw_query(' - SELECT published, timezone + SELECT published, timezone, tz_offset FROM entries WHERE user_id=:user_id AND type=:type @@ -328,8 +328,13 @@ function query_last_eaten($user_id, $type, $content) { $timestamp = strtotime($lastQ->published); // If less than 8 hours ago, use relative time, otherwise show the actual time if(time() - $timestamp > 60*60*8) { - $date = new DateTime($lastQ->published); - $date->setTimeZone(new DateTimeZone($lastQ->timezone)); + if($lastQ->timezone) { + $date = new DateTime($lastQ->published); + $date->setTimeZone(new DateTimeZone($lastQ->timezone)); + } else { + $iso = date_iso8601($lastQ->published, $lastQ->tz_offset); + $date = new DateTime($iso); + } return $date->format('D, M j, g:ia'); } else { $config = array(