Note that there are some explanatory texts on larger screens.

plurals
  1. POChange NSDateFormatter For Dates in Array?
    primarykey
    data
    text
    <p>Right now my dates look like this:<code>`2011-01-01 5:45:23 +0000</code></p> <p>I want them to look like this: <code>2011-01-01 00:00:00 +0000</code> (notice how everything is 00 beside the date, month, and year).</p> <p>I have an array of NSdates which is fetched from this code:</p> <pre><code>NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Session" inManagedObjectContext:self.managedObjectContext]; [request setEntity:entity]; [request setResultType:NSDictionaryResultType]; [request setReturnsDistinctResults:YES]; //set to YES if you only want unique values of the property [request setPropertiesToFetch :[NSArray arrayWithObject:@"timeStamp"]]; //name(s) of properties you want to fetch NSError *error; NSArray *objects = [managedObjectContext executeFetchRequest:request error:&amp;error]; NSArray *data = [objects valueForKey:@"timeStamp"]; NSLog(@"The content of data is%@", data); </code></pre> <p>I want to remove daylight savings and have 0:00:00 for the time aspect of each date, thus I need this NSDateFormatter method:</p> <pre><code>NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease]; [formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"]; // e.g., set for mysql date strings [formatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT"]]; NSString* mysqlGMTString = [formatter stringFromDate:[NSDate date]]; </code></pre> <p>So how can I combine the two to work together?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload