utc

How to convert django.request logger time to UTC?

孤人 提交于 2020-07-23 06:53:06
问题 I have an application in another TIME_ZONE , but I want to keep all generated logs in UTC. I already defined my own Formatter for Python logging, and all logger calls that I have throughout the app, are all using UTC, but django.request logs, are still using locale's app timezone (both logs bellow, were generated by a single request): Django Request Logger: [10/Jun/2020 16:59:52] "POST /api/v1/report/ HTTP/1.1" 200 761 Application Logger: [10/Jun/2020 23:00:02] INFO - REPORT_OK {'country':

How to convert django.request logger time to UTC?

你。 提交于 2020-07-23 06:52:28
问题 I have an application in another TIME_ZONE , but I want to keep all generated logs in UTC. I already defined my own Formatter for Python logging, and all logger calls that I have throughout the app, are all using UTC, but django.request logs, are still using locale's app timezone (both logs bellow, were generated by a single request): Django Request Logger: [10/Jun/2020 16:59:52] "POST /api/v1/report/ HTTP/1.1" 200 761 Application Logger: [10/Jun/2020 23:00:02] INFO - REPORT_OK {'country':

Save and load Utc DateTime with NHibernate

三世轮回 提交于 2020-07-18 05:54:11
问题 I have problems with saving DateTime to an SQL Lite data base. (perhaps also with MS SQL) I want to save a DateTime in UTC time with NHibernate to the database and load it from the database. We work in the hole application with utc time and when we present the time on the ui, we change it to local time. I read a lot about DateTime and NHibernate: http://jameskovacs.com/2011/01/26/datetime-support-in-nhibernate/ http://www.milkcarton.com/blog/2007/01/19/NHibernate+DateTime+And+UTC.aspx

How to keep UTC time in logging while changing the TIME_ZONE settings?

淺唱寂寞╮ 提交于 2020-07-08 11:06:06
问题 I set the time zone in the settings.py file of my django project: TIME_ZONE = 'US/Eastern' and now my logs contain US/Eastern times. I would like to keep an UTC time in my logs. Is that possible? 回答1: Django uses Python's logging facilities, so there shouldn't be anything Django-specific here. According to the logging documentation, setting logging.Formatter.converter = time.gmtime should make all logs output in UTC. Alternatively, you can make your own Formatter class to use UTC: class

How to keep UTC time in logging while changing the TIME_ZONE settings?

余生颓废 提交于 2020-07-08 11:05:06
问题 I set the time zone in the settings.py file of my django project: TIME_ZONE = 'US/Eastern' and now my logs contain US/Eastern times. I would like to keep an UTC time in my logs. Is that possible? 回答1: Django uses Python's logging facilities, so there shouldn't be anything Django-specific here. According to the logging documentation, setting logging.Formatter.converter = time.gmtime should make all logs output in UTC. Alternatively, you can make your own Formatter class to use UTC: class

Convert 2015-06-01T02:31:00+0000 to DateTime object c#

喜夏-厌秋 提交于 2020-06-29 05:03:10
问题 I'm writting an app that consume this webservice: http://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote?format=json as you can see there, the JSON object comes with an utc datetime field. I want to save this information in a simple DateTime object with the following format "yyyy-MM-dd HH:mm:ss". This is my code: DateTime dateParsed = DateTime.Now; DateTime.TryParseExact((string)resource.SelectToken("resource").SelectToken("fields")["utctime"], "yyyy'-'MM'-'dd'T'HH':'mm':'ssz",

Convert time from UTC to GMT with Python

隐身守侯 提交于 2020-06-28 06:25:08
问题 I'm writting a python app that convert YML files to static HTML pages for my blog (static site generator). I want to add an RSS feed. On a some place I read that the publication date must be: <pubDate>Wed, 05 Jul 2017 18:38:23 GMT</pubDate> But I have: <pubDate>2017-07-05T18:38:23+00:00</pubDate> The datetime API from Python is really cumbersome about these. How to convert the string 2017-07-05T18:38:23+00:00 to GMT? Thanks in avanced. 回答1: import datetime basedate="2017-07-05T18:38:23+00:00"

UTC Time Assignment in VBScript

一个人想着一个人 提交于 2020-06-25 08:39:48
问题 Does anyone have a simple means in VBScript to get the current time in UTC? Thanx, Chris 回答1: I use a simple technique Set dateTime = CreateObject("WbemScripting.SWbemDateTime") dateTime.SetVarDate (now()) wscript.echo "Local Time: " & dateTime wscript.echo "UTC Time: " & dateTime.GetVarDate (false) More info on SWbemDateTime If you wanted to convert UTC back to local time do this: Set dateTime = CreateObject("WbemScripting.SWbemDateTime") dateTime.SetVarDate now(),false REM Where now is the

why datetime.now() and datetime.utcnow() return different timestamp

那年仲夏 提交于 2020-06-23 08:16:07
问题 I'm working with datetime and find it difficult to understand how timestamp() works, I (in east coast) want to transform the datetime into timestamp, but I found following difference. Can anyone shed somelight how each of the two code works, are they suppose to act differently (roughly a difference of four hours)? import datetime datetime.datetime.utcnow().timestamp() #1590436949.187297 datetime.datetime.now(tz=datetime.timezone.utc).timestamp() #1590422553.042119 回答1: The timestamp() method

How do I tell postgres a timestamp within a column is UTC?

亡梦爱人 提交于 2020-06-16 08:30:15
问题 We have an application that fetches data from a source and that source present the data with a timestamp in UTC. When our application saves that data to Postgres, it stores that timestamp in a timestamp column without time zone. The default on postgres in our shop is set to our local time, Mountain Time. So that means, I think, that postgres assumes that timestamp is mountain time. How can I query that column so that my result set thinks it's UTC and not the local time zone? More cleary