diff --git a/app/Http/Controllers/TaskController.php b/app/Http/Controllers/TaskController.php index 13d3fec2e0a8..0fec382e74df 100644 --- a/app/Http/Controllers/TaskController.php +++ b/app/Http/Controllers/TaskController.php @@ -56,7 +56,7 @@ class TaskController extends BaseController } return $table->addColumn('created_at', function($model) { return link_to("tasks/{$model->public_id}/edit", Task::calcStartTime($model)); }) - ->addColumn('time_log', function($model) { return gmdate('H:i:s', Task::calcDuration($model)); }) + ->addColumn('time_log', function($model) { return Utils::formatTime(Task::calcDuration($model)); }) ->addColumn('description', function($model) { return $model->description; }) ->addColumn('invoice_number', function($model) { return self::getStatusLabel($model); }) ->addColumn('dropdown', function ($model) { diff --git a/app/Libraries/Utils.php b/app/Libraries/Utils.php index 650a9ef74117..0a42cd634bad 100644 --- a/app/Libraries/Utils.php +++ b/app/Libraries/Utils.php @@ -330,16 +330,6 @@ class Utils return $date->format($format); } - public static function getTimestampOffset() - { - $timezone = new DateTimeZone(Session::get(SESSION_TIMEZONE, DEFAULT_TIMEZONE)); - $datetime = new DateTime('now', $timezone); - $offset = $timezone->getOffset($datetime); - $minutes = $offset / 60; - - return $minutes; - } - public static function toSqlDate($date, $formatResult = true) { if (!$date) { @@ -379,6 +369,13 @@ class Utils return $formatResult ? $dateTime->format($format) : $dateTime; } + public static function formatTime($t) + { + // http://stackoverflow.com/a/3172665 + $f = ':'; + return sprintf("%02d%s%02d%s%02d", floor($t/3600), $f, ($t/60)%60, $f, $t%60); + } + public static function today($formatResult = true) { $timezone = Session::get(SESSION_TIMEZONE, DEFAULT_TIMEZONE); diff --git a/resources/views/tasks/edit.blade.php b/resources/views/tasks/edit.blade.php index b1cafebc3ceb..47dcb6a23d5a 100644 --- a/resources/views/tasks/edit.blade.php +++ b/resources/views/tasks/edit.blade.php @@ -50,7 +50,7 @@

@if ($task->hasPreviousDuration()) - {{ trans('texts.duration') . ': ' . gmdate('H:i:s', $task->getDuration()) }}
+ {{ trans('texts.duration') . ': ' . Utils::formatTime($task->getDuration()) }}
@endif @if (!$task->is_running)