MishieMoo
MishieMoo

Reputation: 6680

UIDatePicker Default Date as 1/1/1970 comes back as 1/1/1969

I set a default date of 1/1/1970 on a date picker. If I don't change the date, but look at datePicker.date it comes out as 1/1/1969. If I change the date, it comes out correctly. Setting the default date to any other date works fine without changing it. It just doesn't seem to like 1/1/1970.

Has anyone encountered this before? What was your solution?

Upvotes: 1

Views: 1687

Answers (2)

MishieMoo
MishieMoo

Reputation: 6680

So the problem was with my format. I was using YYYY in my custom date format, but I should have been using yyyy, as the uppercase is the ISO year-week calendar.

So apparently in the ISO calendar 1/1/1970 == 1/1/1969.

Upvotes: 1

Joe
Joe

Reputation: 57179

When you are setting the date to the default be conscious of the time zone. 1/1/1970 00:00 UTC could easily change the year to 1969 any where in the americas (west of UTC). I am not entirely sure why you would be getting 1/1 as the month and year though.

Upvotes: 3

Related Questions