Question: I'm trying to store today's date in a sqlite table as a string in a 24-hour time format regardless of the user's locale. Because NSDate honours the user's locale, this code returns different results depending on the user's location:

```
NSLog(@"The date is %@", [NSDate date]);

```

If their locale is set to the United Kingdom, where 24-hour time is the default, the above returns
'The date is 2009-09-05 11:17:35', whereas if they're in the United States, where 12-hour time is the default, it returns 'The date is 2009-09-05 11:17:35 AM'.

Is there a way to automatically detect and convert 12-hour time to 24-hour time before committing it to the database? I'm using SQLite Persistent Objects, so I need to provide the date as an NSDate and not NSString.

Answer: 
Update: in the end I chose to override the user's locale before manipulating the date and storing it, by using NSLocale. So, instead of this:

```
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSSS"];  
NSString *formattedDateString = [dateFormatter stringFromDate:self];
```

I did this:

```
NSLocale *POSIXLocale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setLocale:POSIXLocale];  
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSSS"];  

NSString *formattedDateString = [dateFormatter stringFromDate:self];

```

This has the effect of standardising the date format before storing it. For those using sqlitepo who encounter the same issue, the relevant code to amend can be found in NSDate-SQLitePersistence.m on lines 33 and 46. 

Thanks to all who chipped in.
You could use the sqlite `DATETIME` type, and actually store the date instead of a string. You can use `NSDateFormatter` to define how the date is displayed to the user.