unix-timestamp

How to convert NSDate into unix timestamp iphone sdk?

冷暖自知 提交于 2019-12-17 07:01:24
问题 How to convert an NSDate into Unix timestamp? I've read many posts which do the reverse. But I'm not finding anything related to my question. 回答1: I believe this is the NSDate's selector you're looking for: - (NSTimeInterval)timeIntervalSince1970 回答2: A Unix timestamp is the number of seconds since 00:00:00 UTC January 1, 1970. It's represented by the type time_t, which is usually a signed 32-bit integer type (long or int). iOS provides -(NSTimeInterval)timeIntervalSince1970 for NSDate

Convert Unixtime to Datetime SQL (Oracle)

荒凉一梦 提交于 2019-12-17 04:35:19
问题 I have a datetime field(P_DT) and I would like to return all results where P_DT is greater then an input unix timestamp. Does Oracle have any built in functions that can help? In my searchs I find resuts for DateTime to Unix but no Unix to DateTime... 回答1: There are no built-in functions. But it's relatively easy to write one. Since a Unix timestamp is the number of seconds since January 1, 1970 CREATE OR REPLACE FUNCTION unix_ts_to_date( p_unix_ts IN NUMBER ) RETURN DATE IS l_date DATE;

Convert unix time to readable date in pandas dataframe

☆樱花仙子☆ 提交于 2019-12-17 02:27:17
问题 I have a dataframe with unix times and prices in it. I want to convert the index column so that it shows in human readable dates. So for instance I have date as 1349633705 in the index column but I'd want it to show as 10/07/2012 (or at least 10/07/2012 18:15 ). For some context, here is the code I'm working with and what I've tried already: import json import urllib2 from datetime import datetime response = urllib2.urlopen('http://blockchain.info/charts/market-price?&format=json') data =

Getting “unixtime” in Java

左心房为你撑大大i 提交于 2019-12-17 02:26:31
问题 Date.getTime() returns milliseconds since Jan 1, 1970. Unixtime is seconds since Jan 1, 1970. I don't usually code in java, but I'm working on some bug fixes. I have: Date now = new Date(); Long longTime = new Long(now.getTime()/1000); return longTime.intValue(); Is there a better way to get unixtime in java? 回答1: Avoid the Date object creation w/ System.currentTimeMillis(). A divide by 1000 gets you to Unix epoch. As mentioned in a comment, you typically want a primitive long (lower-case-l

events (as a json feed), start end parameters unix timestamp, are different if I change my OS time zone

随声附和 提交于 2019-12-14 03:48:20
问题 I'm using the fullcalendar plugin and would appreciate if someone can give me a hand. I am getting json events through a PHP URL. something like this: $('#calendar').fullCalendar({ events: "/myfeed.php" }); So in my php page that returns the events, I am getting 3 GET parameters: '_' 'start' 'end' The start and end parameter, indicate the date in UNIX timestamp. So far so good, the problem that occurs is that if I change the time zone on my OS. also change these parameters start and end, for

Select records where date == now + 21 days (NOT between)

穿精又带淫゛_ 提交于 2019-12-14 03:24:32
问题 I have a table session_dates with some fields and a timestamp field named timestart . What I would like to do is select all the records from my table where the field timestart (TIMESTAMP) is equal to 21 days from now . Like for example if today is 27 januari -> 17 februari . I know how I can select all between two dates. My SQL Query for between 2 dates: SELECT timestart, timefinish, sessionid FROM sessions_dates WHERE timestart BETWEEN UNIX_TIMESTAMP(NOW()) AND UNIX_TIMESTAMP(DATE_ADD(NOW(),

Date_format conversion is adding 1 year to the border dates

半腔热情 提交于 2019-12-13 15:26:17
问题 When I use DATE_FORMAT for Dec 31st date 2018 year is getting changed to 2019. Can someone help say if this is a bug or I am missing something. import org.apache.spark.sql.functions._ spark.sql("select CAST(1546268400 AS TIMESTAMP)").show(false) Output: 2018-12-31 15:00:00.0 spark.sql("select DATE_FORMAT(CAST(1546268400 AS TIMESTAMP), 'MM/dd/YYYY HH:mm')").show(false) Output: 12/31/ 2019 15:00 回答1: So this doesn't exactly answer your question but the use of YYYY vs yyyy seems crucial here.

Get the correct hour for a UNIX timestamp

泄露秘密 提交于 2019-12-13 14:02:55
问题 I think this is a stupid question, but seems that I cannot find the answer. I have this timestamp: 1295598602. In my php script I have: $date = date('Y-m-d', 1295598602); $hour = date('H', 1295598602) . ':00'; This returns: Date: 2011-01-21 Hour: 03:00 Now I went to an online conversion site to test this. I used this one. But it seems that for this timestamp value it is Fri, 21 Jan 2011 08:30:02 GMT Now, which one is correct? 回答1: Use correct timezone: >> date_default_timezone_get(); 'UTC' >>

UNIX programming

和自甴很熟 提交于 2019-12-13 10:30:33
问题 Hi i want to convert UNIX date to normal date (YYYY-MM-DD) 22222,0,0,0,14387 33333,0,0,0,14170 44444,0,0,0,14244 55555,0,0,0,14190 66666,0,0,0,14528 77777,0,0,0,14200 88888,0,0,0,0 99999,0,0,0,0 here 5th column represents UNIX date i want to convert into 22222,0,0,0,2009-05-23 and similarly remaining rows can any body help me 回答1: A simple awk script ought to do it awk -F, 'BEGIN{OFS=","} { print $1,$2,$3,$4,strftime("%Y-%m-%d",$5) }' myFile.txt Cheers. EDIT: You're not using unix timestamps,

Alarm Manager broadcasts unexpectedly

女生的网名这么多〃 提交于 2019-12-13 05:36:10
问题 I have a application which should fire up an alarm at a specified time stored in the database. The time is stored like (HH:mm) format, 24-hour format. Here is the code. SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); String temp = h+":"+m; Date date = sdf.parse(temp); alarmMgr = (AlarmManager)_c.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(_c, AlarmBroadcastReciever.class); alarmIntent = PendingIntent.getBroadcast(_c, requestCode, intent, 0); alarmMgr.set