javascript - Get GMT time difference between now GMT and 1 January 2013 gmt -


i trying store time difference between 1 jan 2013 , moment save on database. smaller standard of making relative 1970 ;) both in storage , because sending clientside.

as going getrelativetime() quite lot, looking simplicity. might change 1 jan 2013 date of server launch 1st of month in 2013 :d

i keeping client , serverside track in gmt , on nodejs server, server unknown. researched, there solutions, many call them incorrect due , :|

to offer valid answer question:

var ms = new date() - date.utc(2013,0,1); 

but please not this.

  • you end confusing uses system (developers, api clients, database folks, etc.)

  • you not saving in terms of bytes think. javascript number types 64 bits (8 bytes) in memory, see here. how might save in database dependent on database platform, example, mysql datetime type takes 8 bytes, while timestamp type takes 4. range of timestamp smaller, reference here , here.

  • you encounter negative numbers frequently, if app works dates before epoch. work, source of confusion. if isn't aware of adjusted epoch, produce date looks valid, supposed mean different.

  • you throw out potential using many great libraries expect dates work way. convert , custom date standard one, want wrap , unwrap values? not. libraries moment.js use own types, extending or encapsulating standard data types. compatibility higher concern byte space.

there lot of things wrong javascript dates, choice of 1/1/1970 epoch good thing. because can something, doesn't mean should.

also, consider disk space least expensive component running application. millions of records, save few dozen megabytes @ most. let's error on high side , save 200 mb clever hack. amazon's top-tier provisioned iops cloud storage $0.125 per gb per month. congratulations, you've saved $7.68 on entire year.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -