title: Best way to output a timestamp in the user's timezone, in Node.JS
body: <p>My app is logging certain user events for display in the UI. The timestamps are being stored as dates in Mongo, which become JS Date object, with timezone information relative to the server's timezone.</p>
  
  <p>I'm using <a href="http://momentjs.com/docs/" rel="nofollow">moment.js</a> to format the dates, but since my users are in Australia and my app is hosted on <a href="http://www.heroku.com" rel="nofollow">Heroku</a> (server timezone is UTC), the 'local' time that moment.js helpfully outputs aren't what my users want to see.</p>
  
  <p>Moment.js allows you to switch between UTC and 'local' time (on the server), but doesn't seem to let you output in the context of a different timezone.</p>
  
  <p>(Changing the server's timezone not solve the underlying issue, it would also be wrong for some of my users.)</p>
  
  <p>I have tried to use the <a href="https://github.com/TooTallNate/node-time" rel="nofollow">node-time library</a> to change the timezone on the date, which does work if I then simply output the timestamp using Date.toString(), but if the date is wrapped by Moment.js, it reverts back to the server's timezone.</p>
  
  <p>I could wrangle a solution by calculating the difference between user-local timezone and server-local timezone and modifying the date before it is formatted by Moment.js, but I am hoping there is either (a) a more elegant solution, or (b) a good library that will do this.</p>
  
  <p>I could also output the dates in UTC and let a client-side library reformat them, but I would prefer to have a server-side solution.</p>
  
  <p>Does anybody know of a good solution to this, or a library that fills this gap for Node.JS apps? Is there an established best practice for this?</p>