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.
精彩评论