javascript - Understanding momentjs timezones -


i'm using momentjs in project.

to current date , time in given format i'm using this:

moment().format('ddd, d mmm hh:mm'); // tue, 12 may 12:01 

if output , view in browser, see tue, 12 may 12:01. i'm in london utc+1. if did same florida, assume see tue, 12 may 07:01 (utc-4)?

my question

how can make sure views utc+1 time regardless of in world? think following way not sure.

moment().tz('europe/london').format('ddd, d mmm hh:mm'); // tue, 12 may 12:01 

hoping can explain.

yup, should work:

var = new date();    snippet.log("default: " + moment(now).format('ddd, d mmm hh:mm z'));  snippet.log("europe/london: " + moment(now).tz('europe/london').format('ddd, d mmm hh:mm z'));  snippet.log("america/new_york: " + moment(now).tz('america/new_york').format('ddd, d mmm hh:mm z'));
<script src="http://momentjs.com/downloads/moment.js"></script>  <script src="http://momentjs.com/downloads/moment-timezone-with-data-2010-2020.js"></script>  <!-- script provides `snippet` object, see http://meta.stackexchange.com/a/242144/134069 -->  <script src="http://tjcrowder.github.io/simple-snippets-console/snippet.js"></script>


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -