简体   繁体   中英

how to convert date in UTC format using moment?

using date picker I am getting this value "Fri Jan 12 1900 05:21:10 GMT+0521 (India Standard Time)" I want to get it's value in UTC or UTC in milliseconds or long value. here is my code

 app.controller('MainCtrl', function($scope, moment) {
 $scope.UTC ='';
      $scope.IST = 'Fri Jan 12 1900 05:21:10 GMT+0521 (India Standard Time)';
    });

According to the Moment docs :

moment.utc(yourDate).format()

By default, moment parses and displays in local time.

If you want to parse or display a moment in UTC, you can use moment.utc() instead of moment().

This brings us to an interesting feature of Moment.js. UTC mode.

While in UTC mode, all display methods will display in UTC time instead of local time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM