Skip to content

Instantly share code, notes, and snippets.

@freshlogic
Created January 21, 2016 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save freshlogic/57d813c496ca808e9c2f to your computer and use it in GitHub Desktop.
Save freshlogic/57d813c496ca808e9c2f to your computer and use it in GitHub Desktop.
timezones
Before:
<% var daysOld = moment(new Date()).diff(moment(account.createdAt), 'days') + 1; %>
<%= account.username %> joined us <%= pluralize('day', daysOld, true) %> ago on <%= moment.tz(account.createdAt, 'America/New_York').format('MMMM Do, YYYY') %>.
After:
<% var daysOld = moment.tz(new Date(), 'America/New_York').startOf('day').diff(moment.tz(account.createdAt, 'America/New_York').startOf('day'), 'days') + 1; %>
<%= account.username %> joined us <%= pluralize('day', daysOld, true) %> ago on <%= moment.tz(account.createdAt, 'America/New_York').format('MMMM Do, YYYY') %>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment