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 @@
+