diff --git a/app/controllers/web/BlogController.cfc b/app/controllers/web/BlogController.cfc index 719d9a0..b9e0448 100644 --- a/app/controllers/web/BlogController.cfc +++ b/app/controllers/web/BlogController.cfc @@ -969,10 +969,12 @@ component extends="app.Controllers.Controller" { blogData.statusId = 2; blogData.status = "Approved"; if (structKeyExists(blogData, "postCreatedDate") && !isNull(blogData.postCreatedDate) && !isEmpty(blogData.postCreatedDate)) { - blogData.publishedAt = blogData.postCreatedDate; + // Convert the provided date to UTC before saving + blogData.publishedAt = toUTC(blogData.postCreatedDate); } else { - blogData.publishedAt = now(); - blogData.postCreatedDate = now(); + // Use current UTC time + blogData.publishedAt = toUTC(now()); + blogData.postCreatedDate = toUTC(now()); } } else { blogData.statusId = 2; // Under Review @@ -1025,10 +1027,12 @@ component extends="app.Controllers.Controller" { newBlog.status = blogData.status; } if (structKeyExists(blogData, "postCreatedDate") && !isNull(blogData.postCreatedDate) && !isEmpty(blogData.postCreatedDate)) { - newBlog.publishedAt = blogData.postCreatedDate; - newBlog.postCreatedDate = blogData.postCreatedDate; + // Convert the provided date to UTC before saving + newBlog.publishedAt = toUTC(blogData.postCreatedDate); + newBlog.postCreatedDate = toUTC(blogData.postCreatedDate); } else { - newBlog.postCreatedDate = now(); + // Use current UTC time + newBlog.postCreatedDate = toUTC(now()); } newBlog.save(); diff --git a/app/global/functions.cfm b/app/global/functions.cfm index 345536a..838729d 100644 --- a/app/global/functions.cfm +++ b/app/global/functions.cfm @@ -3,6 +3,17 @@ public function GetSignedInUserId(){ return structKeyExists(session, "userID") ? session.userID : 0 } + +/** + * Convert a local datetime to UTC using server's timezone offset + * @localTime The datetime to convert to UTC + * @return The datetime in UTC + */ +public datetime function toUTC(required datetime localTime) { + var tzInfo = GetTimeZoneInfo(); + var offsetSeconds = tzInfo.utcTotalOffset * 60; + return dateAdd("s", -offsetSeconds, arguments.localTime); +} public function GetUserRoleId(){ return 3; } diff --git a/app/views/layout.cfm b/app/views/layout.cfm index 3f1293b..d336720 100644 --- a/app/views/layout.cfm +++ b/app/views/layout.cfm @@ -17,15 +17,15 @@ - + - + - + - + - + @@ -806,6 +806,21 @@ + \ No newline at end of file diff --git a/app/views/web/BlogController/create.cfm b/app/views/web/BlogController/create.cfm index b634408..bd9850d 100644 --- a/app/views/web/BlogController/create.cfm +++ b/app/views/web/BlogController/create.cfm @@ -79,7 +79,7 @@ - + Leave empty to use the current date and time @@ -108,4 +108,35 @@ - \ No newline at end of file + + diff --git a/app/views/web/BlogController/partials/_blogList.cfm b/app/views/web/BlogController/partials/_blogList.cfm index 25e50b4..22b5af8 100644 --- a/app/views/web/BlogController/partials/_blogList.cfm +++ b/app/views/web/BlogController/partials/_blogList.cfm @@ -74,7 +74,7 @@

#htmlEditFormat(blogs.fullName)#

-