SODashServer/lib/office/getTimeAndDate.js
Martin Donnelly 6e1993c220 App work
2016-04-20 14:48:48 +01:00

66 lines
1.5 KiB
JavaScript

function getTimeAndDate() {
//Define today's date in meetingInfo format
// Get the timestamp in the UTC timezone
var now = new Date();
var utc_timestamp = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(),
now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(),
now.getUTCSeconds(), now.getUTCMilliseconds());
//Define today's date in string format [year month date]
//convert year to string
var year = now.getUTCFullYear();
var yearStr = year.toString();
//convert month to string
var month = now.getUTCMonth();
if (month < 9) {
month += 1;
monthStr = ["0" + month.toString()];
} else {
month += 1;
monthStr = month.toString();
};
//convert date to string
var date = now.getUTCDate();
if (date < 10) {
dateStr = ["0" + date.toString()];
} else {
dateStr = date.toString();
};
//Get UTC hours, minutes
var hours = now.getUTCHours() + 1;
if (hours == 0) {
var hoursStr = ["00"];
} else if (hours < 10){
var hoursStr = ["0" + hours.toString()]
} else {
var hoursStr = hours.toString();
}
var mins = now.getUTCMinutes();
if (mins == 0) {
var minsStr = ["00"];
} else if (mins < 10){
var minsStr = ["0" + mins.toString()]
} else {
var minsStr = mins.toString();
}
//dateToday, timeNow
var dateToday = [yearStr + monthStr + dateStr];
var timeNow = [hoursStr + minsStr];
this.date = dateToday;
this.time = timeNow;
};
module.exports.getTimeAndDate = getTimeAndDate; //public function
/*
var timeNow = new getTimeAndDate();
console.log(timeNow.time);
console.log(timeNow.date); */