utc

What is the best way to store dates of birth in MongoDB?

試著忘記壹切 提交于 2019-12-10 04:10:30
问题 I've read a lot about how to store simple dates (without time) in MongoDB, but I still can't find an answer. Some say to store theme like MongoDate (date + utc time), some say to store theme like a YYYYMMDD string, and some like other funny ways. The rightest way seems to be MongoDate, but why should I store a date of birth as a date with UTC time? Plus, the date of birth "1990-05-21" is stored as "1990-05-20T23:00:00Z" (the day before): this date shouldn't change depending on timezone, but

How to convert a UTC date format String to Date format in java?

做~自己de王妃 提交于 2019-12-09 19:29:09
问题 I have a requirement where the date is in UTC format like: Thu Jan 1 19:30:00 UTC+0530 1970 . I want to convert in to normal date format dd-MM-yyyy HH:mm:ss .Below is the code that i tried. DateFormat formatter = new SimpleDateFormat("E,MMM dd,yyyy h:mmaa"); String today = formatter.format("Thu Jan 1 19:30:00 UTC+0530 1970"); SimpleDateFormat f = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy"); Date d = f.parse(masterDetailsJsonObject.get("cols1").toString()); But it throws an exception

Lua游戏开发之时区问题

我们两清 提交于 2019-12-09 17:28:22
转自: https://www.cnblogs.com/meteoric_cry/p/9637040.html 目前大部分游戏都采用了Lua语言进行功能开发,在进行多语种发行的时候就会遇到时区显示的问题。以韩国版本为例,场景如下: 1、服务器处于固定的位置,比如放在首尔机房; 2、玩家所处的位置不确定,可能在韩国,或者是出差在其它国家或地区; 需求: 无论在哪个国家或地区,统一显示服务器的当前时间。在PC上查看,即便在国内测试的时候也显示韩国首尔的时间(比北京时间快1个小时)。 实现: -- 北京时间 local serverTime = 1536722753 -- 2018/09/12 11:25 function getTimeZone() local now = os.time() return os.difftime(now, os.time(os.date("!*t", now))) end -- 8 hour * 3600 seconds = 28800 seconds local timeZone = getTimeZone()/ 3600 print("timeZone : " .. timeZone) local timeInterval = os.time(os.date("!*t", serverTime)) + timeZone * 3600 + (os

Python - From DST-adjusted local time to UTC

梦想与她 提交于 2019-12-09 11:20:29
问题 A specific bank has branches in all major cities in the world. They all open at 10:00 AM local time. If within a timezone that uses DST, then of course the local opening time also follows the DST-adjusted time. So how do I go from the local time to the utc time. What I need is a function to_utc(localdt, tz) like this: Arguments: localdt: localtime, as naive datetime object, DST-adjusted tz: timezone in the TZ-format, e.g. 'Europe/Berlin' Returns: datetime object, in UTC, timezone-aware EDIT:

Converting UTC DateTime to local DateTime

◇◆丶佛笑我妖孽 提交于 2019-12-09 08:32:48
问题 I have the following ASP.Net MVC Controller method: public ActionResult DoSomething(DateTime utcDate) { var localTime = utcDate.ToLocalTime(); } The problem is that localTime will have the exact same value as utcDate. I assume this is because utcDate doesn't know it has a UTC value. So my question is how can I convert utcDate (which I KNOW is UTC) into local? 回答1: If you know the DateTime contains a UTC value, you can use the following: DateTime iKnowThisIsUtc = whatever; DateTime

Converting Epoch to Date in Matlab

∥☆過路亽.° 提交于 2019-12-09 06:09:37
问题 I have an array of Epoch milliseconds (array of numbers) in Matlab. I would like to convert these into UTC date-time format, such as DD-MM-YYYY HH:MM. Is there a pre-defined Matlab way to do this or will I have to write my own function? 回答1: Suppose, you start with a vector time_unix , then: >> time_unix = 1339116554872; % example time >> time_reference = datenum('1970', 'yyyy'); >> time_matlab = time_reference + time_unix / 8.64e7; >> time_matlab_string = datestr(time_matlab, 'yyyymmdd HH:MM

PHP strtotime returning false for UTC time

家住魔仙堡 提交于 2019-12-09 03:58:43
问题 My colleague and I are obtaining different results from some unit tests that use strtotime. The discrepancy originates in this line: $value = strtotime('2050-05-01T20:10:29.410Z'); on my machine, this result returns the following: int(2535048629) whereas my colleague's version returns false We are both using PHP version 5.4.14 and PHPUnit 3.724. Has anyone got any idea what is causing this discrepancy, and is there a more robust approach? 回答1: This is because he is on 32-bit and you are on 64

How to store date-time in UTC into a database using EclipseLink and Joda-Time?

一曲冷凌霜 提交于 2019-12-09 03:23:43
问题 I have been fumbling with the following EclipseLink Joda-Time converter for a long time to store date-time in UTC into MySQL database with no success at all. import java.util.Date; import org.eclipse.persistence.mappings.DatabaseMapping; import org.eclipse.persistence.mappings.converters.Converter; import org.eclipse.persistence.sessions.Session; import org.joda.time.DateTime; public final class JodaDateTimeConverter implements Converter { private static final long serialVersionUID = 1L;

Using time zones in a PHP web application

对着背影说爱祢 提交于 2019-12-09 00:05:07
问题 I've been looking around for a few hours now about what's the best way to use timezones in a PHP/MySQL web application, finding a definitive answer is hard. From what I've learnt so far it is best to store everyones stuff in the database in UTC (correct me if I am wrong). When a user registers I will ask them for there timezone and then store that against there user. This would be in this format as a dropdown menu: <option value="Europe/London">(GMT) Greenwich Mean Time : London</option> The

How to have WebApi querystring parameter binding keep UTC dates?

大憨熊 提交于 2019-12-08 21:53:47
问题 I am sending in my querystring a UTC date, e.g. &EndDate=2000-01-02T03%3a04%3a05.0060000Z And my controller parameter binds it in a complex object, e.g. public async Task<DocumentsRequest> GetEchoFromUriDocumentsAsync( [FromUri] DocumentsRequest request) { return request; } What I've managed to figure out is that my object after parameter binding, changes my UTC date to a local date + offset. Here is a snippet of my test case [TestMethod] public void Should_generate_querystring_and_parameter