Moment Timezone 0.5.45-2024a

解析和显示任何时区的日期。

下载

moment-timezone-with-data-10-year-range.js moment-timezone-with-data-10-year-range.min.js 11.2k moment-timezone-with-data-1970-2030.js moment-timezone-with-data-1970-2030.min.js 19.4k moment-timezone-with-data.js moment-timezone-with-data.min.js 36.8k moment-timezone.js (无数据) moment-timezone.min.js 3k

安装

bower install moment-timezone --save # bower
npm install moment-timezone --save   # npm
yarn add moment-timezone             # Yarn
	

以任何时区格式化日期

var jun = moment("2014-06-01T12:00:00Z");
var dec = moment("2014-12-01T12:00:00Z");

jun.tz('America/Los_Angeles').format('ha z');  // 5am PDT
dec.tz('America/Los_Angeles').format('ha z');  // 4am PST

jun.tz('America/New_York').format('ha z');     // 8am EDT
dec.tz('America/New_York').format('ha z');     // 7am EST

jun.tz('Asia/Tokyo').format('ha z');           // 9pm JST
dec.tz('Asia/Tokyo').format('ha z');           // 9pm JST

jun.tz('Australia/Sydney').format('ha z');     // 10pm EST
dec.tz('Australia/Sydney').format('ha z');     // 11pm EST

在时区之间转换日期

var newYork    = moment.tz("2014-06-01 12:00", "America/New_York");
var losAngeles = newYork.clone().tz("America/Los_Angeles");
var london     = newYork.clone().tz("Europe/London");

newYork.format();    // 2014-06-01T12:00:00-04:00
losAngeles.format(); // 2014-06-01T09:00:00-07:00
london.format();     // 2014-06-01T17:00:00+01:00