utc

Javascript Date类型

耗尽温柔 提交于 2019-12-21 07:11:02
Date 类型使用自 UTC 1970 年 1 月 1日 午夜 开始经过的毫秒数来保存日期。 创建日期对象 var now = new Date();//获取当前日期 Date.parse ( ) 接受一个表示日期的字符串参数,返回相应毫秒数。这个日期格式通常因地区而异。 实际上直接将日期字符串传给Date构造函数,也会后台先调用一下Date.parse(), 所以下面两条等价 var someDate = new Date(Date.parse("May 25, 2004")); var someDate = new Date("May 25, 2004"); Date.UTC() 参数分别是 年份、月份(0-11)、天(1-31)、小时(0-23)、分钟、秒、毫秒数。省略的参数自动填充为0(天数为1) 同样这个UTC参数也可以直接传给Date构造函数 // 2005年5月5日下午5:55:55 var allFives = new Date(Date.UTC("2005, 4, 5, 17, 55, 55")); var allFives = new Date("2005, 4, 5, 17, 55, 55"); Date.now() 返回当前时刻的那个毫秒数 继承的方法 Date的toLocaleString() 会返回日期和时间(会包含AM或PM) 但不包含时区信息

Storing a leap second in SQL Server 2008

梦想的初衷 提交于 2019-12-21 03:43:19
问题 This weekend is an extra long one as there will be an extra second inserted after 23:59:59 on June 30th. We have a system that logs a lot of data around the clock and one of the business rules is that no two records can be logged as having occurred at the same time, to within one second. We're using UTC datetimes along with the new datetimeoffset data type, but as far as I can tell they won't let you have more than 60 seconds in a minute. Certainly, this throws an error: select datediff(ss,

Is there ever a good reason to store time not in UTC?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 17:32:19
问题 I am wondering if there are any good reasons to ever store time information in anything other that UTC (GMT)? I believe that this is a solid rule for all software engineering. The conversion to local time is merely a translation that happens at the UI layer for display purposes. I have also seen cases where the translatation is needed in order to implement an algorithm correctly (for handling midnight date changes, etc.). 回答1: In general it I find it better to use UTC. Sometimes you might

Is there ever a good reason to store time not in UTC?

自作多情 提交于 2019-12-20 17:32:03
问题 I am wondering if there are any good reasons to ever store time information in anything other that UTC (GMT)? I believe that this is a solid rule for all software engineering. The conversion to local time is merely a translation that happens at the UI layer for display purposes. I have also seen cases where the translatation is needed in order to implement an algorithm correctly (for handling midnight date changes, etc.). 回答1: In general it I find it better to use UTC. Sometimes you might

Linux查看设置系统时区

大兔子大兔子 提交于 2019-12-20 12:54:32
关于时区的概念,其实初中地理课已经涉及,很多人都多少了解一些,可能只是细节搞不太清楚。为什么会将地球分为不同时区呢?因为地球总是自西向东自转,东边总比西边先看到太阳,东边的时间也总比西边的早。东边时刻与西边时刻的差值不仅要以时计,而且还要以分和秒来计算。整个地球分为二十四时区,每个时区都有自己的本地时间。在国际无线电通信场合,为了统一起见,使用一个统一的时间,称为通用协调时(UTC, Universal Time Coordinated)。UTC与格林尼治平均时(GMT, Greenwich Mean Time)一样,都与英国伦敦的本地时相同。 关于时间的几个标准,如下所示,具体可以Google、Baidu搜索一下。 CST:中国标准时间(China Standard Time),这个解释可能是针对RedHat Linux。 UTC:协调世界时,又称世界标准时间,简称UTC,从英文国际时间/法文协调时间”Universal Time/Temps Cordonné”而来。中国大陆、香港、澳门、台湾、蒙古国、新加坡、马来西亚、菲律宾、澳洲西部的时间与UTC的时差均为+8,也就是UTC+8。 GMT:格林尼治标准时间(旧译格林威治平均时间或格林威治标准时间;英语:Greenwich Mean Time,GMT)是指位于英国伦敦郊区的皇家格林尼治天文台的标准时间

C++ timegm conversion DST to a certain timezone at a given time in the future?

余生长醉 提交于 2019-12-20 07:34:45
问题 I need an accurate conversion in my class from UTC time to local time of a given timezone, with or without DST in effect. My problem is, that when I use struct tm I have to provide the tm_isdst member, or leave it -1 to be determined automatically. from mktime(3) - linux man page: "The value specified in the tm_isdst field informs mktime() whether or not daylight saving time (DST) is in effect for the time supplied in the tm structure: a positive value means DST is in effect; zero means that

C++ timegm conversion DST to a certain timezone at a given time in the future?

China☆狼群 提交于 2019-12-20 07:34:20
问题 I need an accurate conversion in my class from UTC time to local time of a given timezone, with or without DST in effect. My problem is, that when I use struct tm I have to provide the tm_isdst member, or leave it -1 to be determined automatically. from mktime(3) - linux man page: "The value specified in the tm_isdst field informs mktime() whether or not daylight saving time (DST) is in effect for the time supplied in the tm structure: a positive value means DST is in effect; zero means that

Create a local date from a UTC date string in Moment.js

和自甴很熟 提交于 2019-12-20 04:58:07
问题 Given a UTC date string (formatted: YYYYMMDDHHmmss) I'd like to create a date with the local timezone using Moment.js. I have tried the following: var utcDateStr = '20140101120000'; var localDate = moment.utc(utcDateStr, 'YYYYMMDDHHmmss'); //actual: true //desired: false console.log(localDate._isUTC) //actual: "Wed Jan 01 2014 12:00:00 GMT+0000" //desired: "Wed Jan 01 2014 07:00:00 GMT-0500" console.log(localDate.toString()) How do I create a date that is formatted in the local time zone by

How to fetch UTC dates with JavaScript?

我与影子孤独终老i 提交于 2019-12-20 04:30:48
问题 I want to get the current UTC date with Javascript. How can I do this? There seems to be methods for getting the time in UTC: date.getUTCHours(); How can I get the date ? 回答1: There are UTC getters for date, day, full year, hour, minutes, month, etc. To get the date specifically, you might find getUTCDate useful. Without seeing more of your code, I can only suggest this: date.getUTCDate(); 来源: https://stackoverflow.com/questions/2650328/how-to-fetch-utc-dates-with-javascript

Web and Database server settings to get UTC timezone “right”

北战南征 提交于 2019-12-20 03:46:10
问题 I'm overwhelmed trying to get this right: We've got servers located across a dozen time zones, with Apache and MySQL running on all or some of them, as well as MySQL hosted on Amazon RDS. I want to know "Best Practices", or how to otherwise configure each MySQL and PHP installation so that when a row is added to the database from PHP I'm certain that the value there is actually the UTC time when the event happened, regardless of where the server is located when it happened. Presenting it to