epoch

DB2 timestampdiff function returning unexpected results

…衆ロ難τιáo~ 提交于 2019-11-30 09:17:29
问题 I'm using the following syntax TIMESTAMPDIFF(2, CHAR(CREATED - TIMESTAMP('1970-01-01 00:00:00')) where CREATED is of type TIMESTAMP and the database is DB2. The intension is to get the timestamp converted to millis from epoch. If there is a better function that would be more helpful. Sample data: For 2011-10-04 13:54:50 returned value is 1316613290 but actual value should be 1317732890 (got from http://www.epochconverter.com) Query to run SELECT TIMESTAMPDIFF(2, CHAR(TIMESTAMP('2011-10-04 13

Convert an ISO date to seconds since epoch in linux bash

我只是一个虾纸丫 提交于 2019-11-30 08:02:40
问题 I have a date in the ISO format YYYY-MM-DDTHH:SS (e.g. 2014-02-14T12:30). I'd like to convert it in seconds since epoch using only the date command in linux bash. All the dates refer to UTC locale. I know that this question is easily eligible for duplicate... there are billions of questions about converting dates from one format to another but I can't find my particular scenario thank you... 回答1: With GNU date, specify the date to parse with -d and seconds since epoch with %s $ date -d"2014

How to convert python timestamp string to epoch?

大憨熊 提交于 2019-11-30 03:52:06
问题 I have the following string: mytime = "2009-03-08T00:27:31.807Z" How do I convert it to epoch in python? I tried: import time p = '%Y-%m-%dT%H:%M:%S' int(time.mktime(time.strptime(s, p))) But it does not work with the 31.807Z . 回答1: There are two parts: Convert the time string into a broken-down time. See How to parse ISO formatted date in python? Convert the UTC time to "seconds since the Epoch" (POSIX timestamp). #!/usr/bin/env python from datetime import datetime utc_time = datetime

Localizing Epoch Time with pytz in Python

眉间皱痕 提交于 2019-11-30 02:01:19
Im working on converting epoch timestamps to dates in different timezones with pytz. What I am trying to do is create a DateTime object that accepts an Olson database timezone and an epoch time and returns a localized datetime object. Eventually I need to answer questions like "What hour was it in New York at epoch time 1350663248?" Something is not working correctly here: import datetime, pytz, time class DateTime: def __init__(self, timezone, epoch): self.timezone = timezone self.epoch = epoch timezoneobject = pytz.timezone(timezone) datetimeobject = datetime.datetime.fromtimestamp( self

Get Current date in epoch from Unix shell script

人盡茶涼 提交于 2019-11-29 22:46:48
How to get the current date value in epoch i.e., number of days elapsed since 1970-1-1. I need solution in unix shell script. Stephan202 Update : The answer previously posted here linked to a custom script that is no longer available, solely because the OP indicated that date +'%s' didn't work for him. Please see UberAlex' answer and cadrian's answer for proper solutions. In short: For the number of seconds since the Unix epoch use date(1) as follows: date +'%s' For the number of days since the Unix epoch divide the result by the number of seconds in a day (mind the double parentheses!): echo

mm/dd/yyyy format to epoch with PHP

与世无争的帅哥 提交于 2019-11-29 19:10:50
问题 I have a mysql table that relies on the unix epoch time stamp equivalent of the date of the entry to sort and filter in various parts of the website. I'm trying to implement a date picker that will enter the date into the form field in the mm/dd/yyyy format. I've been struggling with converting that date into the unix epoch format to add that entry in the row field. All the attempts I've made have resulted in generating the current day epoch time stamp. Does anyone have any idea how I can

Convert string to a epoch time in Excel

£可爱£侵袭症+ 提交于 2019-11-29 14:35:51
I am trying to convert string in following format: 20130817T140000Z (17th Aug 2013 at 14:00) to epoch time (seconds since 1970) in an MS Excel 2013. Tried cell formatting, but it doesn't work with T and Z or the format in general. This will convert your date into somethign Excel will understand, If you have your date in Cell A1, Then convert that into Epoch Time =(DATE(LEFT(A1,4),MID(A1,5,2),MID(A1,7,2)) + TIME(MID(A1,10,2),MID(A1,12,2),MID(A1,14,2))-25569)*86400) Try this: A1=20130817T140000Z A2=DATE(LEFT(A1,4),MID(A1,5,2),MID(A1,7,2)) A3=(DATEDIF("01/01/1970 00:00:00",A2,"D")+TIME(MID(A1,10

In Python, is epoch time returned by time() always measured from Jan 1, 1970?

时光怂恿深爱的人放手 提交于 2019-11-29 13:18:52
Is the epoch start time in Python independent of the platform (i.e. always 1/1/1970)? Or is it platform dependent? I want to serialize datetimes (with second accuracy) on various machines running Python, and be able to read them back on different platforms, possibly also using different programming languages (than Python). Is serializing epoch time a good idea? The documentation says: To find out what the epoch is, look at gmtime(0) . I would interpret this to mean that no particular epoch is guaranteed. See also this Python-Dev thread . That seems to confirm the notion that, in practice, the

DateTime, the Epoch and DocumentDb

旧街凉风 提交于 2019-11-29 10:58:30
So I read this very interesting blog on working with datetime in Azure DocumentDb . The problem being that, right now, Azure DocumentDb does not support range search on datetime fields. The reason for that is that DocumentDb is based on json and that has no datetime type, therefore one usually puts it in a string of xml datetime format. (obviously Mongo does not have that issue, it's bson format adds the datetime type (among others)) Anyway, the article describes storing the datetime in json in an epoch (unix) time, essentially storing the datetime as an amount of seconds since 01-01-1970. One

Convert Epoch Time string to Time

吃可爱长大的小学妹 提交于 2019-11-29 08:57:08
I've been looking for a way to convert a string (in Epoch time) into a date. Basically, I need to take this: 1360440555 (in string form) and make it into this: Feb 9 12:09 2013 . I've been looking at strptime and strftime, but neither seems to be working for me. Any suggestions? Edit: Thanks, guys. I converted it to an int with atoi() , cast it as time_t , then ran ctime() on it. Worked perfectly! If only you had that value in an integer instead of a string, you could just call ctime . If only there were some way to convert a string to an integer.... time_t c; c = strtoul( "1360440555", NULL,