Commit 329ff0e1 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

Merge "Bug 1723784: Fixing 'Last login' date to display in correct timezone"

parents 1b7c0130 9dd5c16d
......@@ -976,6 +976,8 @@ function useractivity_stats_table($limit, $offset, $extra, $institution, $urllin
}
$data = array();
$timezone = new DateTimeZone(date_default_timezone_get()); // get timezone we are in
$offsettime = $timezone->getOffset(new DateTime("now")); // work out offset in seconds
if ($aggregates['totalresults'] > 0) {
foreach ($aggregates['aggregations']['UsrId']['buckets'] as $item) {
$obj = new stdClass();
......@@ -994,14 +996,12 @@ function useractivity_stats_table($limit, $offset, $extra, $institution, $urllin
$obj->lastactivity = ($lastactivity) ? get_string($lastactivity, 'statistics') : '';
$obj->profileurl = profile_url($item['key']);
$date = $item['LastLogin']['value'] / 1000; // convert from UTC milliseconds
$timezone = new DateTimeZone(date_default_timezone_get()); // get timezone we are in
$offsettime = $timezone->getOffset(new DateTime("now")); // work out offset in seconds
if ($offset < 0) {
$date -= $offsettime;
}
if ($offset > 0) {
if ($offsettime < 0) {
$date += $offsettime;
}
if ($offsettime > 0) {
$date -= $offsettime;
}
$obj->lastlogin = $item['LastLogin']['value'] ? date('d F Y, H:i a', $date) : '';
$obj->actions = $item['doc_count'];
$data[] = $obj;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment