Pass date as milliseconds since 1970

Transactions
= 2017-09-19 22:20:35 -06:00
parent f230e11e52
commit 4417065a15
2 changed files with 3 additions and 5 deletions

View File

@ -29,10 +29,11 @@ export class EventService {
let fd = new FormData();
fd.append("title",event.title);
fd.append("description",event.description);
fd.append("startDate",event.startDate.toLocaleString());
fd.append("startDate",event.startDate.getTime().toString());
fd.append("endDate",event.endDate.toLocaleString());
console.log(new Date(event.startDate).toLocaleString());
var milli = event.startDate.getTime().toString();
console.log(new Date(milli).toLocaleString());
return this.http.post(EVENTS_ADD_URL,fd,{withCredentials:true})
.map(d=>{ return d.json(); })

View File

@ -60,10 +60,7 @@ exports.insertEvent = function(titleOrEventObject, startDateOrCallbackFunction,
console.log("start date: " + startDateOrCallbackFunction);
var startDte = new Date(startDateOrCallbackFunction);
console.log("new start date: " + startDte);
startDte.setTime(startDte.getTime() + startDateOrCallbackFunction.getTimezoneOffset()*60*1000);
console.log("date with offset: " + startDte);
var endDte = new Date(endDate);
endDte.setTime(endDte.getTime() + endDate.getTimezoneOffset()*60*1000);
connection.query("INSERT INTO Events (CreatedDate,ModifiedDate,Id,Title,StartDate,EndDate,Description) VALUES(CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,NULL,?,?,?,?)",[titleOrEventObject,startDte,endDte,description],function(error,result){
if (error){
console.log(error);