timestamp

Workaround for datetime timestamp() on windows for dates preceeding 1970-01-01

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-15 10:18:28
问题 I am currently trying to generate numerical features in a dataset by converting the dates to timestamps. If run on Mac, it works flawlessly, on windows it throws an OS Error: [Errno 22] Invalid argument which is probably due to windows not supporting unix timestamps from before 1970-01-01. I have dates from 1955 upwards. Here is my code: import time import datetime current_timestamp = time.time() df.loc[:, "FEATURE_num"] = df["FEATURE"].apply(lambda d: datetime.datetime.strptime(d, '%Y-%m-%d'

Leap in time in PHP's function time()

江枫思渺然 提交于 2020-01-15 06:19:33
问题 Using the timestamp of PHP's time() function, I show the current time to the user with date(). Format: H:i => 13:57 But sometimes there seem to be leaps in time. My windows clock was showing 13:40 when I visited the page. But my website said 14:XX. I don't know the exact time any more. Another example: A user accessed the page "Who is online?" at 00:16. A user was listed with the time for his last action being 00:39. The last action time is written to the database on every page load. So the

Delete records after 15 minutes

倾然丶 夕夏残阳落幕 提交于 2020-01-15 05:51:53
问题 I've got an inactive system. It is supposed to delete users from inactive table after 15 minutes. I have also a code that logs the user out if it cant be found in that table. The inactive script updates user on every page refresh. This is the inactive code I tried and it doesn't work so far: $result = mysqli_query($con,"SELECT * FROM inactive"); while($row = mysqli_fetch_array($result)) if ($row['inactive'] > timestampadd(MINUTE, -15, now())) { }else { $db_query = "DELETE FROM inactive WHERE

SQL Server 2016 timestamp data type

血红的双手。 提交于 2020-01-15 05:26:51
问题 I have the following problem: I am using an archiving software that exports its data to an MS SQL database, one of the columns being designated Timestamp_S (which represents the unix time), and it is an 32 bit integer. This database needs to be queried by a different reporting software. The problem is that the reporting software requires its entries to have a field named "Timestamp" and also that the data type be SQL timestamp. I am currently trying to select the data that the archiving

Convert unix/epoch time to formatted date - unexpected date

喜夏-厌秋 提交于 2020-01-15 05:26:28
问题 Im trying to convert a timestamp to a human readable date and time. I tried: String dateSt = 1386580621268; Log.i("*****", "date st is = "+dateSt); long unixSeconds = Long.parseLong(dateSt); Log.i("*******", "unix seconds is = "+unixSeconds); Date date = new Date(unixSeconds*1000L); // *1000 is to convert seconds to milliseconds SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); // the format of your date String formattedDate = sdf.format(date); System.out.println(formattedDate); The

How to convert from Timestamp to Mongo ObjectID

徘徊边缘 提交于 2020-01-15 04:27:49
问题 I know that we can use getTimestamp() to retrieve the timestamp from the ObjectId, but is there any way to generate an ObjectId from a timestamp? More specifically, if I have an input of month and year , then I want to convert it into Mongo ObjectID to query in db, how should I do this? 回答1: try this, > ObjectId("5a682326bf8380e6e6584ba5").getTimestamp() ISODate("2018-01-24T06:09:42Z") > ObjectId.fromDate(ISODate("2018-01-24T06:09:42Z")) ObjectId("5a6823260000000000000000") Works from mongo

Android TimeZone Turkey GMT

怎甘沉沦 提交于 2020-01-14 14:19:47
问题 For 2016 Turkish Government decided to stay GMT+3 timezone to save daylight, but on android: Calendar calendar = Calendar.getInstance(); TimeZone tz = TimeZone.getTimeZone("UTC"); calendar.setTimeInMillis(timestamp * 1000); Date currentTimeZone = (Date) calendar.getTime(); calendar.add(Calendar.MILLISECOND, tz.getOffset(calendar.getTimeInMillis())); So the problem is; it's showing GMT+3 for the date before November: Wed Oct 26 18:00:00 GMT+03:00 2016 but for after November: Mon Nov 07 20:00

How to use the MySQL CONVERT_TZ function in a JPQL or HQL query

谁说胖子不能爱 提交于 2020-01-14 13:46:11
问题 I currently have table in a MySQL database which has a startDate and endDate which are both timestamps . This is linked to the code using hibernate. I can return these by using the following HQL SELECT startDate, endDate FROM Reservation where id = :id What I am trying to do is return these dates based on a given timezone. I know MySQL has a function CONVERT_TZ which can return the dates based on a given timezone, I'm wondering if HQL has a similar function? I know HQL has a TIMESTAMP_WITH

PostgreSQL dump and restore in different timezone

只谈情不闲聊 提交于 2020-01-14 09:20:29
问题 I have two databases running on different servers in different timezones. There is a couple of tables which contains timestamp with timezone . I need to dump data from one database and to import it to another with correct timestamp and correct timezone. I use following command to dump data: pg_dump -a DB_NAME > dump.sql I see data are in old timestamp and timezone format: 2013-11-29 14:30:00+02 Then I use command to another server to restore dump: psql -d DB_NAME -f dump.sql And I see that

SQL convert yyyymmdd to timestamp in BigQuery?

丶灬走出姿态 提交于 2020-01-13 20:31:07
问题 I'm attempting to convert a string to a timestamp within SQL. The question is really quite simple, how can I convert this string into a timestamp that starts at midnight on that day? Within my database I also have a field stored in timestamp_micros either one of these could work and I think converting the micros to a timestamp would be easier than the string. For example 20170118 => timestamp Query: WITH allTables as ( SELECT event.date as date, count(*) as totalSessions, count(DISTINCT user