Skip to content

Instantly share code, notes, and snippets.

Working with Dates, Times, and Timezones

Top 10 recommendations for developers

Update: tzTime (documentation) is now available seperately from Lumenize. The examples below still work because tzTime is a dependency of Lumenize and included in that package (as well as Rally's App SDK v2.0p6 or greater). However, Lumenize includes a lot more functionality around time-series and temporal model aggregations, OLAP Cube, etc. If you just want the Time object, just grab tzTime.

What's the correct query clause to get all the transactions from March? The naive answer is "2012-03-01" <= eventTimestamp <= "2012-03-31" but what if the person worked in the eastern US and wanted timezone taken into account? Then the correct answer is "2012-03-01T05" <= eventTimestamp < "2012-04-01T04". Notice how the timeshift for the begging of March is different from the end. Getting this right is mind bendingly diff

// vendor
var express = require('express');
var app = express();
// depending on the placement, we can either catch or override routes
app.use(app.router);
// every route in the routes/user.js file will be served under /user
app.use('/user', require('./routes/user').middleware);