English 中文(简体)
sqlite writing a date into an email
原标题:

I am exporting a date value from sqlite and placing it into an email. The date appears like this 279498721.322872

I am using Objective C in an Iphone App. Does anyone know how to make this export out as a regular date whether it is all number like 2009-02-10 or anything legible?

最佳回答

Thanks for the responses. The answer came from my Guru Alex Cone. He told me to use the following:

NSTimeInterval tempInterval = (NSTimeInterval)sqlite3_column_double(statement, 4);

The tempInterval variable can then be loaded into the the NSDate method.

问题回答

Well, if you take the number 279498721.322872 and throw it into an NSDate object using +dateWithTimeIntervalSinceReferenceDate, you get (here in the MDT timezone): 2009-11-09 15:32:01 -0700, which was just under 4 hours ago. If that s the time you re expecting, then formatting it is as simple as using an NSDateFormatter.

However, the thing to notice is that sqlite (by default) stores dates as textual representations (unless you specify differently in the sql statement). So the real question here is "where are you getting that number from?"

echo date("Y-m-d",time(279498721.322872));




相关问题
Mysql compaire two dates from datetime?

I was try to measure what is faster and what should be the best way to compare two dates, from datetime record in MySql db. There are several approaches how to grab a date from date time, but I was ...

iPhone Date Picker rolls over to 2010 on December 27th?

So I implemented a UIDatepicker in one of my applications for scheduling and autodialing teleconferences... everything is pretty much ready to go except, while testing I noticed that when the date ...

Convert date Python

I have MMDDYY dates, i.e. today is 111609 How do I convert this to 11/16/2009, in Python?

specifying date format when using $form->inputs() in CakePHP

I am wondering if there is a way to specify the date format in the forms created using CakePHP s $form->inputs(); Please note that this is not the individual $form->input() but instead $form->inputs() ...

NSDateFormat, super simple! Where am I screwing up?

Ok, this is really simple, maybe I m a getting a bit burnt out, but seems like it should work, Query XML feed, put out date string, format, display in a cell. The issue is I m a getting a NULL ...

sqlite writing a date into an email

I am exporting a date value from sqlite and placing it into an email. The date appears like this 279498721.322872 I am using Objective C in an Iphone App. Does anyone know how to make this export ...

热门标签