diff --git a/app/Http/Controllers/PageController.php b/app/Http/Controllers/PageController.php index e250d8c85..a645ede02 100644 --- a/app/Http/Controllers/PageController.php +++ b/app/Http/Controllers/PageController.php @@ -4,6 +4,7 @@ use Activity; use BookStack\Exceptions\NotFoundException; use BookStack\Repos\UserRepo; use BookStack\Services\ExportService; +use Carbon\Carbon; use Illuminate\Http\Request; use BookStack\Http\Requests; use BookStack\Repos\BookRepo; @@ -214,8 +215,14 @@ class PageController extends Controller } else { $draft = $this->pageRepo->saveUpdateDraft($page, $request->only(['name', 'html', 'markdown'])); } - $updateTime = $draft->updated_at->format('H:i'); - return response()->json(['status' => 'success', 'message' => 'Draft saved at ' . $updateTime]); + + $updateTime = $draft->updated_at->timestamp; + $utcUpdateTimestamp = $updateTime + Carbon::createFromTimestamp(0)->offset; + return response()->json([ + 'status' => 'success', + 'message' => 'Draft saved at ', + 'timestamp' => $utcUpdateTimestamp + ]); } /** diff --git a/package.json b/package.json index 7d1aa1a6a..866109c2a 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "dropzone": "^4.0.1", "laravel-elixir": "^3.4.0", "marked": "^0.3.5", + "moment": "^2.12.0", "zeroclipboard": "^2.2.0" } } diff --git a/resources/assets/js/controllers.js b/resources/assets/js/controllers.js index 83e58ee4b..340a0f1a1 100644 --- a/resources/assets/js/controllers.js +++ b/resources/assets/js/controllers.js @@ -1,5 +1,7 @@ "use strict"; +var moment = require('moment'); + module.exports = function (ngApp, events) { ngApp.controller('ImageManagerController', ['$scope', '$attrs', '$http', '$timeout', 'imageManagerService', @@ -367,7 +369,8 @@ module.exports = function (ngApp, events) { if (isMarkdown) data.markdown = $scope.editContent; $http.put('/ajax/page/' + pageId + '/save-draft', data).then((responseData) => { - $scope.draftText = responseData.data.message; + var updateTime = moment.utc(moment.unix(responseData.data.timestamp)).toDate(); + $scope.draftText = responseData.data.message + moment(updateTime).format('H:m'); if (!$scope.isNewPageDraft) $scope.isUpdateDraft = true; }); }