unix-timestamp

Convert python datetime to timestamp in milliseconds

人盡茶涼 提交于 2019-12-03 06:38:33
问题 How to convert a human readable time with the format 20.12.2016 09:38:42,76 to Unix timestamps in milliseconds ? I found a lot of similar questions, but didn't found this specific question/answer. 回答1: In Python 3 this can be done in 2 steps: Convert timestring to datetime object Multiply the timestamp of the datetime object by 1000 to convert it to milliseconds. For example like this: from datetime import datetime dt_obj = datetime.strptime('20.12.2016 09:38:42,76', '%d.%m.%Y %H:%M:%S,%f')

How do I create a Unix timestamp on Android?

怎甘沉沦 提交于 2019-12-03 06:13:28
问题 How do I create a Unix timestamp on Android? I want to create a URL post request with a Unix timestamp on the end of the url. 回答1: long unixTime = System.currentTimeMillis() / 1000L; 回答2: It's quite simple: long timestamp = Calendar.getInstance().getTime() / 1000; 来源: https://stackoverflow.com/questions/10177552/how-do-i-create-a-unix-timestamp-on-android

group by month of unix timestamp field

那年仲夏 提交于 2019-12-03 05:44:38
I'm trying to get my code to output in the following format: january 2012 - 34 february 2012 - 23 where 34 and 23 would be a count of the total rows that fall within that month that have the id_dealership of 7. I need this to output all data for every month that an assignment was ever made. The assignments table structure is as follows: id_dealer (int) date_assigned (int) I've tried this but it does not work at all: SELECT MONTH(date_assigned), YEAR(date_assigned), COUNT(*) FROM assignments GROUP BY MONTH(date_assigned), YEAR(date_assigned) SELECT MONTH(FROM_UNIXTIME(date_assigned)), YEAR(FROM

python get time stamp on file in mm/dd/yyyy format

大憨熊 提交于 2019-12-03 04:45:31
I'm trying to get the datestamp on the file in mm/dd/yyyy format time.ctime(os.path.getmtime(file)) gives me detailed time stamp Fri Jun 07 16:54:31 2013 How can I display the output as 06/07/2013 You want to use time.strftime() to format the timestamp; convert it to a time tuple first using either time.gmtime() or time.localtime() : time.strftime('%m/%d/%Y', time.gmtime(os.path.getmtime(file))) Michael from datetime import datetime from os.path import getmtime datetime.fromtimestamp(getmtime(file)).strftime('%m/%d/%Y') You can create the datetime object using the ctime str like you mention

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 to represent dates before epoch as a UNIX timestamp

纵饮孤独 提交于 2019-12-03 01:31:16
It occurred to me that I'm not aware of a mechanism to store dates before 1970 jan. 1 as Unix timestamps. Since that date is the Unix "epoch" this isn't much of a surprise. But - even though it's not designed for that - I still wish to store dates in the far past in Unix format. I need this for reasons. So my question is: how would one go about making unix-timestamps contain "invalid" but still working dates? Would storing a negative amount of seconds work? Can we even store negative amounts of seconds in a unix-timestamp? I mean isn't it unsigned? Also if I'm correct then I could only store

Convert Unix timestamp into datetime

谁说胖子不能爱 提交于 2019-12-03 00:08:00
I have the following data frame > head(try) creates time 1 128.29508 1417392072 3 236.98361 1417392072 7 98.45902 1417392072 9 157.44068 1417392131 10 227.38333 1417392131 11 242.03390 1417392131 > str(try) 'data.frame': 102968 obs. of 2 variables: $ creates: num 128.3 237 98.5 157.4 227.4 ... $ time : Factor w/ 26418 levels "1417392071","1417392072",..: 2 2 2 3 3 3 3 3 5 5 ... I am unable to convert the UNIX timestamp into datetime using the following methods I tried > head(as.POSIXlt(as.numeric(try$time),origin="1970-01-01",tz="GMT")) [1] "1970-01-01 00:00:02 UTC" "1970-01-01 00:00:02 UTC"

Oracle conversion of UNIX timestamp to timestamp with time zone

丶灬走出姿态 提交于 2019-12-02 22:09:54
问题 Trying to convert UNIX timestamp to Oracle timestamp with timezone. Expecting to see different output, however datetime part is the same. What is wring ? select (timestamp '1970-01-01 00:00:00' + numtodsinterval(1204104116656/1000,'second')) at time zone tz_offset('EST') from dual; Output: 27-FEB-08 09.21.56 .656000000 AM -05:00 select (timestamp '1970-01-01 00:00:00' + numtodsinterval(1204104116656/1000,'second')) at time zone tz_offset('PST') from dual; Output: 27-FEB-08 09.21.56 .656000000

Datetime comparison in Unix

跟風遠走 提交于 2019-12-02 20:57:41
问题 I had two datetime strings like below... 2014-09-03T02:23:09Z and 2014-09-03T03:24:57Z Now, I have to assign the two datetimes to some variables and compare them, like this: d1=2014-09-03T02:23:09Z d2=2014-09-03T03:24:57Z if (d1 < d2 ) I browsed many websites but couldn't find a solution. I tried the approach below but it doesn't work. #set -vx date1=`date -d "2014-09-03T04:27:23Z" +"%Y-%m-%dT%TZ"` date2=`date -d "2014-09-03T02:23:09Z" +"%Y-%m-%dT%TZ"` date3=`date -d "2014-09-03T05:23:09Z" +"

How do I create a Unix timestamp on Android?

拜拜、爱过 提交于 2019-12-02 18:42:40
How do I create a Unix timestamp on Android? I want to create a URL post request with a Unix timestamp on the end of the url. long unixTime = System.currentTimeMillis() / 1000L; Aleks G It's quite simple: long timestamp = Calendar.getInstance().getTime() / 1000; 来源: https://stackoverflow.com/questions/10177552/how-do-i-create-a-unix-timestamp-on-android