Skip to content

Instantly share code, notes, and snippets.

@fntneves
Created July 26, 2015 22:59
Show Gist options
  • Save fntneves/c791939bd71df4d6b479 to your computer and use it in GitHub Desktop.
Save fntneves/c791939bd71df4d6b479 to your computer and use it in GitHub Desktop.
Moment.JS - Convert UTC to Local Time
$.fn.format = function() {
return this.each(function() {
var $this = $(this);
var time = $this.attr("datetime");
var localTime = moment.utc(time).local().format();
$this.attr("datetime", localTime).timeago();
return this;
});
};
@pmartinez8241
Copy link

Nice! thank you for posting

@guruprasaathm
Copy link

This helped! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment