[sqlitepo] Converting 12-Hour time to 24-Hour time before storing

1 view
Skip to first unread message

nick

unread,
Sep 6, 2009, 6:20:16 AM9/6/09
to sqlitepersistentobjects-user
When storing an [NSDate] using sqlitepo, the stored value differs
depending on whether the iPhone has 24-Hour time switched on or off
(under Settings>General>Date & Time).

In 12-Hour time mode, the string written to the table is: 2009-09-06
01:09:11 PM.8550
In 24-Hour time mode, the string written to the table is: 2009-09-06
13:09:11.8550

This creates problems when retrieving and comparing date fields later.
For example, the following code returns entries when 24-Hour time mode
is on, but no entries when it's turned off:

todayTasks = [Task findByCriteria: @"WHERE date(due) BETWEEN
'1980-01-01' AND date('now','localtime') ORDER BY due"];

Is this a bug, and is there a way I can workaround it to always store
dates in 24-hour time mode? Very grateful for any help.
Reply all
Reply to author
Forward
0 new messages