unix-timestamp

Mysql: Convert DB from local time to UTC

落爺英雄遲暮 提交于 2019-12-02 17:42:29
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 lang) First you need to make sure the mysql.time_zone_name table is populated. If it's empty, you can

How to convert Unix timestamp into Swift NSDate object? [closed]

南楼画角 提交于 2019-12-02 17:31:11
I'm getting dates as Unix timestamps through my API and I want to convert them into NSDate objects in Swift. How can I do that? Try this: var date = NSDate(timeIntervalSince1970: timeInterval) 来源: https://stackoverflow.com/questions/26844132/how-to-convert-unix-timestamp-into-swift-nsdate-object

Getting current unixtimestamp using Moment.js

爱⌒轻易说出口 提交于 2019-12-02 16:02:01
I want to get the Unix TimeStamp using Moment.js. I can find many functions which convert timestamp to date in moment.js. I know that I can easily get the unix timestamp by using the following JavaScript function: Math.floor(new Date().getTime()/1000) . But I want to use Moment.js to get the same result. Is there any direct function in moment.js to get the current timestamp? Matt Johnson-Pint To find the Unix Timestamp in seconds: moment().unix() The documentation is your friend. :) For anyone who finds this page looking for unix timestamp w/ milliseconds, the documentation says moment()

How to sort the files according to the time stamp in unix? [closed]

谁都会走 提交于 2019-12-02 14:25:01
How to sort the files according to the time stamp in unix? I need to sort the files and also based on time they created. File modification: ls -t Inode change: ls -tc File access: ls -tu "Newest" one at the bottom: ls -tr None of this is a creation time. Most Unix filesystems don't support creation timestamps. Use -t on ls. e.g:. ls -tr or ls -ltr 来源: https://stackoverflow.com/questions/6023726/how-to-sort-the-files-according-to-the-time-stamp-in-unix

Java Converting 19-digit Unix Timestamp to a Readable Date

喜欢而已 提交于 2019-12-02 13:13:10
I am trying to convert 19 digit Unix timestamp such as 1558439504711000000 (one and a half quintillion ) into a readable date/time format. My timestamp ends with 6 zeros which suggests the time is in nano seconds. I have come across some examples where people have used time zones which I don't need. Another example uses ofEpochSecond like so: Instant instant = Instant.ofEpochSecond(seconds, nanos); But I am not sure whether I need to use ofEpochSecond. The code below gives my most recent approach of achieving this: String timeStamp = "1558439504711000000"; long unixNanoSeconds = Long.parseLong

group by month and year, count from another table

邮差的信 提交于 2019-12-02 10:40:06
im trying to get my query to group rows by month and year from the assignments table, and count the number of rows that has a certain value from the leads table. they are linked together as the assignments table has an id_lead field, which is the id of the row in the leads table. d_new would be a count of the assignments for leads for the month whose website is newsite.com d_subprime would be a count of the assignments for leads for the month whose website is not newsite.com here are the tables being used: `leads` id (int) website (varchar) `assignments` id_lead (int) date_assigned (int) heres

Java - convert unix time in miliseconds with time zone to timestamp

五迷三道 提交于 2019-12-02 10:23:51
问题 I have a string for example: 1517439600000+0100 and I want to convert it to unix time in miliseconds with no timezone. how can I do it? p.s. 1) I cant use substring(0,5) and add 3.6m miliseconds to the string because I have a lot of time zone once is +0100 and then is +0200 and etc... 2) if it more easier to convert to regular timestamp like YYYY-mm-dd hh:mm:ss it should be fine. 回答1: You can do something like: String sign = "+"; String [] parts = time.split(sign); Long millis = Long

Datetime comparison in Unix

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 07:57:51
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" +"%Y-%m-%dT%TZ"` #date1=`date -d "2014-09-03T04:27:23Z"` #date2=`date -d "2014-09-03T02:23:09Z"` #date3=

How to handle MySQL timezone in script

↘锁芯ラ 提交于 2019-12-02 05:19:50
I am developing a mobile application. From the application calls are made to a web service which runs different queries based on mode (?mode=xx) In some of those queries I use date functions like DATE(NOW()). The data stored in the MySQL database is stored in GMT-7 (Mountain Time Canada). I have yet to register a domain/host for this web service but when I do lets say it is hosted in a different city such as Toronto (which is GMT-5 - 2 hours ahead). Then at 10:05pm Mountain Time Canada a user uses the application to send a web request call which has a query like: SELECT DATE(NOW()) Because the

Java - convert unix time in miliseconds with time zone to timestamp

末鹿安然 提交于 2019-12-02 05:15:10
I have a string for example: 1517439600000+0100 and I want to convert it to unix time in miliseconds with no timezone. how can I do it? p.s. 1) I cant use substring(0,5) and add 3.6m miliseconds to the string because I have a lot of time zone once is +0100 and then is +0200 and etc... 2) if it more easier to convert to regular timestamp like YYYY-mm-dd hh:mm:ss it should be fine. You can do something like: String sign = "+"; String [] parts = time.split(sign); Long millis = Long.parseLong(parts[0]); String zoneOffset = sign + parts[1]; LocalDate date = Instant.ofEpochMilli(millis).atZone