utc

Timestamps and time zone conversions in Java and MySQL

匿名 (未验证) 提交于 2019-12-03 08:28:06
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm developing a Java application with a MySQL database on a server located in a different time zone from mine, and I am trying to decide between using DATETIME or TIMESTAMP on my database. After reading questions like Should I use field 'datetime' or 'timestamp'? , and the MySQL documentation , I decided TIMESTAMP was better for me as it converts values to UTC for storage, and back to the current time zone for retrieval. Also, as user Jesper explains in this thread, java.util.Date objects are internally only a UTC timestamp (i.e. number of

Joda Time: Convert UTC to local

﹥>﹥吖頭↗ 提交于 2019-12-03 07:37:09
I want to convert a Joda Time UTC DateTime object to local time. Here's a laborious way to do it which seems to work. But there must be a better way. Here's the code (in Scala) without surrounding declarations: val dtUTC = new DateTime("2010-10-28T04:00") println("dtUTC = " + dtUTC) val dtLocal = timestampLocal(dtUTC) println("local = " + dtLocal) def timestampLocal(dtUTC: DateTime): String = { // This is a laborious way to convert from UTC to local. There must be a better way. val instantUTC = dtUTC.getMillis val localDateTimeZone = DateTimeZone.getDefault val instantLocal = localDateTimeZone

Is there a difference between the UTC and Etc/UTC time zones?

筅森魡賤 提交于 2019-12-03 06:28:28
问题 In the PHP documentation, list of supported time zones, UTC is listed twice: UTC Etc/UTC Is there any conceptual difference between those two, or are they just synonyms? 回答1: Etc/UTC is the specified for the time zone whose display name is UTC . That is, they're long and short names for the same timezone, per IANA's time zone database. 回答2: Firstly, to answer the question: There is NO difference between UTC and Etc/UTC time zones. Etc/UTC is a timezone in the Olson-timezone-database (tz

How can I get an accurate UTC time with Python?

老子叫甜甜 提交于 2019-12-03 05:56:31
I wrote a desktop application and was using datetime.datetime.utcnow() for timestamping, however I've recently noticed that some people using the application get wildly different results than I do when we run the program at the same time. Is there any way to get the UTC time locally without using urllib to fetch it from a website? Ned Deily Python depends on the underlying operating system to provide an accurate time-of-day clock. If it isn't doing that, you don't have much choice other than to bypass the o/s. There's a pure-Python implementation of an NTP client here . A very simple-minded

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

好久不见. 提交于 2019-12-03 04:52:07
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.). In general it I find it better to use UTC. Sometimes you might need a local time. Then I would rather go with UTC + timezone information. In general times can be extremely

互联网渗透测试之Wireshark的高级应用

耗尽温柔 提交于 2019-12-03 04:37:15
互联网渗透测试之Wireshark的高级应用 1.1说明 在本节将介绍 Wireshark的一些高级特性 1.2. "Follow TCP Stream" 如果你处理 TCP协议,想要查看Tcp流中的应用层数据,"Following TCP streams"功能将会很有用。如果你项查看telnet流中的密码,或者你想尝试弄明白一个数据流。或者你仅仅只需要一个显示过滤来显示某个TCP流的包。这些都可以通过Wireshark的"Following TCP streams"功能来实现。 在包列表中选择一个你感兴趣的 TCP包,然后选择Wireshark工具栏菜单的"Following TCP Streams"选项(或者使用包列表鼠标右键的上下文菜单)。然后,Wireshark就会创建合适的显示过滤器,并弹出一个对话框显示TCP流的所有数据。如 图 1.1 “"Follow TCP Stream"对话框” 所示 注意 值得注意的是:Follow Tcp Stream会装入一个显示过滤来选择你已经选择的Tcp流的所有包。 1.2.1. "Follow TCP Stream"对话框 图 1.1. "Follow TCP Stream"对话框 流的内容出现的顺序同他们在网络中出现的顺序一致。从 A到B的通信标记为红色,从B到A的通信标记为蓝色。当然,如果你喜欢的话你可以从"Edit

Mysql: Convert DB from local time to UTC

三世轮回 提交于 2019-12-03 04:28:49
问题 I need to convert an existing (datetime fields) db from local time ut UTC. The values are stored ad datetimes on a server with time zone CET (+1) (with summertime +2). When selecting data I use UNIX_TIMESTAMP() , which magically compensates for everything, ie, time zone shift and dst (if i've read the docs right). I'm moving the db to a new server with UTC as system time. Simply subtracting -1 H won't work, as summer time is +2. Any ideas for a clever way to do this? (using sql or some script

How do I get the current UTC offset (time zone)?

匿名 (未验证) 提交于 2019-12-03 03:10:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How do I get the current UTC offset (as in time zone, but just the UTC offset of the current moment)? I need an answer like "+02:00". 回答1: There are two parts to this question: Get the UTC offset as a boost::posix_time::time_duration Format the time_duration as specified Apparently, getting the local time zone is not exposed very well in a widely implemented API. We can, however, get it by taking the difference of a moment relative to UTC and the same moment relative to the current time zone, like this: boost::posix_time::time_duration get

python converting string in localtime to UTC epoch timestamp

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have strings in YMD hms format that had the timezone stripped. But I know they are in Eastern time with daylight savings time. I am trying to convert them into epoch timestamps for UTC time. I wrote the following function: def ymdhms_timezone_dst_to_epoch(input_str, tz="US/Eastern"): print(input_str) dt = datetime.datetime.fromtimestamp(time.mktime(time.strptime(input_str,'%Y-%m-%d %H:%M:%S'))) local_dt = pytz.timezone(tz).localize(dt) print(local_dt.strftime('%Y-%m-%d %H:%M:%S %Z%z')) utc_dt = local_dt.astimezone(pytz.utc) print(utc_dt

Python - Setting a datetime in a specific timezone (without UTC conversions)

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Just to be clear, this is python 2.6, I am using pytz. This is for an application that only deals with US timezones, I need to be able to anchor a date (today), and get a unix timestamp (epoch time) for 8pm and 11pm in PST only. This is driving me crazy. > pacific = pytz.timezone("US/Pacific") > datetime(2011,2,11,20,0,0,0,pacific) datetime.datetime(2011, 2, 11, 20, 0, tzinfo=<DstTzInfo 'US/Pacific' PST-1 day, 16:00:0 STD>) > datetime(2011,2,11,20,0,0,0,pacific).strftime("%s") '1297454400' zsh> date -d '@1297454400' Fri Feb 11 12:00:00 PST