function dailyEventMessage() {
var googleCalendarId = "xxxxxx@group.calendar.google.com";
var calendar = CalendarApp.getCalendarById(googleCalendarId);
var today = new Date();
var tomorrow = new Date(today.getFullYear(), today.getMonth(),today.getDate()+1);
var tomorrowEventList = calendar.getEventsForDay(tomorrow);
const date = new Date(tomorrow)
const tomorrowdateresult = date.toLocaleDateString('th-TH', {
year: 'numeric',
month: 'long',
day: 'numeric',
weekday: 'long',
})
var message = "";
for (var i = 0; i < tomorrowEventList.length; i++) {
var eventTitle = "Task: " + tomorrowdateresult + "\n" + "**"+ tomorrowEventList[i].getTitle()+"**";
var eventTime = "Timebegin: " + tomorrowEventList[i].getStartTime().toTimeString().slice(0,5)
+"-"+ tomorrowEventList[i].getEndTime().toTimeString().slice(0,5);
var eventDescription = "Details: " + tomorrowEventList[i].getDescription();
message += "\n" + eventTitle + "\n" + eventTime + "\n" + eventDescription + "\n";
}
if (message === "") {
return;
}
Logger.log(message);
sendMessage(message);
}
我发现的问题是变量 eventtime,它显示为 12 小时格式。前任。03.00-04.00 但实际上我在谷歌日历中设置的时间为 15.00-16.00
谁能建议如何将其更改为 24 小时格式。Thks
人到中年有点甜
相关分类