Permalink
Browse files

Use moment.utc(..).unix() to post dates to database

Is this correct? I'm not sure..
  • Loading branch information...
1 parent c10de3e commit 061cab16d8b6126c15c78f1a81476cdbae2b933f @dresende committed Jul 23, 2012
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/databases/helpers.js
View
5 lib/databases/helpers.js
@@ -1,5 +1,6 @@
var util = require("util");
var events = require("events");
+var moment = require("moment");
var re_order_mode = /^(a|de)sc$/i;
@@ -166,7 +167,7 @@ module.exports = {
}
if (util.isDate(data[k])) {
id.push(escapeCb(k) + " = " + opts.date_convert_fmt);
- val.push(Math.round(data[k].getTime() / 1e3));
+ val.push(moment.utc(data[k]).unix());
continue;
}
id.push(escapeCb(k) + " = ?");
@@ -193,7 +194,7 @@ module.exports = {
}
if (util.isDate(data[k])) {
escapes.push(opts.date_convert_fmt);
- val.push(Math.round(data[k].getTime() / 1e3));
+ val.push(moment.utc(data[k]).unix());
continue;
}
escapes.push("?");

0 comments on commit 061cab1

Please sign in to comment.