Skip to content
Search

Moment Timezone

lastmod 2021-10-08created 2021-10-082 edits

Parse and display dates in any timezone.

How to install

npm install moment-timezone

Default Timezone

moment.tz.setDefault() sets the global standard time.

require('moment-timezone');
var moment = require('moment');
moment.tz.setDefault("Asia/Seoul");
exports.moment = moment;

Now you can format with moment.

moment().format();     // 기본적인 포맷으로 변환한 현재 시간
moment().valueOf();    // 현재 시간 값(BigInt 크기로서 현재 시간을 millisecond로 나타낸 숫자 값)    
moment().format('MM월 DD일, HH시 mm분 ss초');    // 해당 포맷으로 변환한 현재 시간
moment({hour: 0}).valueOf();      // 현재 날의 특정 시간을 millisecond로 나타낸 숫자 값.(0시 0분)
moment({hour: 0 , minute: 30}).valueOf();     // 현재 날의 특정 시간을 millisecond로 나타낸 숫자 값.(0시 30분)

For reference, moment.tz.guess() gets the default reference time zone.

See also

Favorite site

author Zer0 sitemap