开发者

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

开发者 https://www.devze.com 2023-03-07 15:46 出处:网络
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 开发者_高级运

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?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消