calculate epoch time in iPad

I have an array which contains time in HH:mm:ss format.

I want to convert this into epoch time. To convert a particular time into epoch, date along with time should be passed.

I want to pass today's date along with the time from array.

For example 09:15:30 (date 22/12/2011) which is a string, should be converted into 1324525530000 (corresponding epoch value)

How should I convert this ??

Any help is appreciated.

-------------Problems Reply------------

Maybe you can get an idea looking at this snippet:

NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] initWithSafeDateFormat:@"dd/MM/yyyy HH:mm:ss"];
NSDate *date = [dateFormatter dateFromString:dateString];
NSTimeInterval epoch = [date timeIntervalSince1970];

Anyway you can have a look to NSDateFormatter and NSDate in the reference docs.

That looks like an epoch time in milliseconds - as far as I know it's supposed to be in seconds.

You can use NSDateFormatter to parse a string and convert it to a NSDate. This date can then return the seconds since 1970. If you really need it, simply multiply this by 1000.

Category:iphone Views:0 Time:2011-12-22

Related post

  • IOS - angle between ipad and pitch-roll-layer 2012-01-02

    i used core motion in IOS to calculate the angle between ipad and pitch-roll-layer, but i didnt know how i can calculate the angle between ipad-layer and pitch-roll-layer from yaw-, pitch- and roll-value. In the below image, i want to calculate the α

  • Bash: subtracting 10 mins from a given time 2010-09-09

    In a bash script, if I have a number that represents a time, in the form hhmmss (or hmmss), what is the best way of subtracting 10 minutes? ie, 90000 -> 85000 --------------Solutions------------- This is a bit tricky. Date can do general manipulat

  • calculate seconds-to-date for pre-epoch date/times using MS VS2003 2008-11-13

    I have this routine that calculates the seconds-to-date for a struct tm. On Linux my implementation using mktime works fine, but mktime on windows VS2003/.NET 1.1 returns -1 for pre-epoch datetimes. How do I calculate meaningful time_t values (i.e. v

  • SQLite query that calculates if Unix epoch time occurs on today's date 2011-02-24

    I have an integer column that holds a Unix epoch time value. I want to calculate if it falls within today. For example, let today be the 24th day in the month. The query should return rows that fall on the 24th, but not ones that fall on the 23rd or

  • How to get/calculate margin width of grouped UITableView on iPad or iPhone 2011-03-13

    I have a grouped table view that I use to display several properties of a model. Those properties can be longish so I calculate the height of the cells in tableView:heightForCellAtIndexPath: using NSString's sizeWithFont:constrainedToSize:lineBreakMo

  • iPad - Portrait and Landscape - Calculate how much angle it made with my desk 2010-11-25

    I'm creating an app for iPad that works both in landscape and portrait mode. I want to place one edge of iPad on my desk and slant(angle) it. Now I want to measure how much angle it made with my desk. Using accelerometer, I'm getting X,Y and Z values

  • How to calculate the diameter of the TouchPoint on an iPhone,iPad and Android Device? 2011-08-17

    Now i understand we can have 5 touch points by default in iPhone and have varied touch points enabled onto the different SDKs. However i have accomplished registering the touch points and getting distances, actual number of touch points. I would want

  • ActionScript 3.0 + Calculate timespan between two dates? 2008-10-03

    In ActionScript 3.0, is there an automatic way to calculate the number of days, hours, minutes and seconds between two specified dates? Basicly, what I need is the ActionScript equivalent of the .NET Timespan class. Any idea? --------------Solutions-

  • How can I calculate the age of a person in year, month, days? 2009-01-17

    I want to calculate the age of a person given the date of birth and the current date in years, months and days relative to the current date. For example: >>> calculate_age(2008, 01, 01) 1 years, 0 months, 16 days Any pointer to an algorithm

  • How can I calculate the number of days between two dates in Perl? 2009-05-04

    Heylo, I want to calculate (using the default Perl installation only) the number of days between two dates. The format of both the dates are like so 04-MAY-09. (DD-MMM-YY) I couldn't find any tutorials that discussed that date format. Should I be bui

  • Calculating Future Epoch Time in C# 2009-05-25

    I was able to find example code to get the current timestamp in Linux Epoch (Seconds since Midnight Jan 1st 1970), however I am having trouble finding an example as to how to calculate what the Epoch will be in the future, say for example 10 minutes

  • how to calculate difference between two dates using java 2009-10-12

    I'm using Java's java.util.date class in Scala and want to compare a date object and the current time. I know I can calculate the delta by using getTime(): (new java.util.Date()).getTime() - oldDate.getTime() However, this just leaves me with a Long

  • Converting epoch time to "real" date/time 2009-11-07

    What I want to do is convert an epoch time (seconds since midnight 1/1/1970) to "real" time (m/d/y h:m:s) So far, I have the following algorithm, which to me feels a bit ugly: void DateTime::splitTicks(time_t time) { seconds = time % 60; time /= 60;

  • Calculate date difference having a large range with PHP 2010-02-02

    I need to calculate the number of decades between 2 dates possible spanning form 1708 until today - the limitations are as far as I can gather are 1970/1901 within PHP native functions. Can anyone advise? Thanks! --------------Solutions-------------

  • "date_part('epoch', now() at time zone 'UTC')" not the same time as "now() at time zone 'UTC'" in postgresql 2010-04-11

    I'm writing a web based front end to a database (PHP/Postgresql) in which I need to store various dates/times. The times are meant to be always be entered on the client side in the local time, and displayed in the local time too. For storage purposes

  • Storing date and time as epoch vs native datetime format in the database 2010-04-12

    For most of my tasks I find it much easier to work with date and time in the epoch format: it's trivial to calculate timespan or determine if some event happened before or after another, I don't have to deal with time-zone issues if the data comes fr

  • Calculate date from numeric value 2010-04-21

    The number 71867806 represents the present day, with the smallest unit of days. Sorry guy's, caching owned me, it's actually milliseconds! How can I calculate the currente date from it? (or) convert it into an Unix timestamp? Solution shouldn't use l

  • Fitting an Image to Screen on Rotation iPhone / iPad? 2010-06-02

    I have been playing around with one of the iPhone examples from Apple' web site (ScrollViewSuite) . I am trying to tweak it a bit so that when I rotate the the iPad the image will fit into the screen in landscape mode vertical. I have been successful

  • Rendering a Long Document on iPad 2010-06-13

    I'm implementing a document viewer with highlighting/annotation capabilities for a custom document format on iPad. The documents are kind of long (100 to 200 pages, if printed on paper) and I've had a hard time finding the right approach. Here are th

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.144 (s). 11 q(s)