js 獲取指定時區當前時間

2022-03-08 03:49:51 字數 543 閱讀 7305

var timezone = 8; //

目標時區時間,東八區 東時區正數 西市區負數

var offset_gmt = new date().gettimezoneoffset(); //

本地時間和格林威治的時間差,單位為分鐘

var nowdate = new date().gettime(); //

本地時間距 1970 年 1 月 1 日午夜(gmt 時間)之間的毫秒數

var targetdate = new date(nowdate + offset_gmt * 60 * 1000 + timezone * 60 * 60 * 1000);

var nowtime=targetdate.getfullyear() + "-" + parseint(targetdate.getmonth() + 1) + "-" + targetdate.getdate()+" "+targetdate.gethours()+":"+targetdate.getminutes()+":"+targetdate.getseconds();

js 獲取當前gmt時間 js 獲取時區

js的時區函式 設datename為建立的乙個date物件 datename.gettimezoneoffset 取得當地時間和gmt時間 格林威治時間 的差值,返回值以分鐘為單位 舉例 根據本地時間獲得gmt時間和任意時區的時間 d new date 建立乙個date物件 localtime d....

python pytz 獲取指定時區的時間

例項如下 import pytz import datetime 查詢中國所擁有的時區 cn pytz.country timezones cn 查詢美國所擁有的時區 us pytz.country timezones us 查詢南韓所擁有的時區 kr pytz.country timezones ...

kettle中js 獲取當前時間帶時區格式

需求字段 created at timestamp 6 with time zone 參照格式 2019 12 28 02 01 00.000000 08 00 00 用js進行轉換後插入資料表。使用常見方式 var mydate new date var cyear mydate.getfully...