Scratch that - timezone issue.
Resolved by changing that first line to:

              DateTime dt = DateTime.SpecifyKind (dpDeliveryDate.Date, 
DateTimeKind.Local).ToLocalTime();

Cheers
Alec

From: [email protected] 
[mailto:[email protected]] On Behalf Of Alec Tucker
Sent: Wednesday, 18 January 2012 1:48 PM
To: [email protected]
Subject: [MonoTouch] UIDatePicker.Date issue

Hi all,

I'm adding a UIDatePicker onto a view using IB and calling it dpDate (by adding 
an outlet).

The following code then consistently shows a date which is one day earlier than 
the date selected on screen:

              UIAlertView ua = new UIAlertView("Selected Date", 
dpDate.Date.ToString(), null,"Cancel", null);
              ua.Show ();

I've tried setting the time zone in advance, and I've also tried this:

              DateTime dt = DateTime.SpecifyKind (dpDeliveryDate.Date, 
DateTimeKind.Local);
              UIAlertView ua = new UIAlertView("Selected Date", 
dt.ToShortDateString(), null,"Cancel", null);

Both still give me a date which is one day earlier than the date selected. I 
have the UIDateTimePicker in Date mode, so that the time is not visible.

Anyone got any ideas?

Thanks
Alec

This message was scanned at Wednesday, January 18, 2012 2:47:50 AM GMT by Trend 
Micro IMHS on behalf of

White Clarke Group - www.whiteclarkegroup.com<http://www.whiteclarkegroup.com>.



White Clarke Group Ltd - Registered in England - Registered number 03435619.

Registered address: Fairfax House, 15 Fulwood Place, London, WC1V 6AY



This message was scanned at Wednesday, January 18, 2012 2:48:05 AM GMT by Trend 
Micro IMHS on behalf of White Clarke Group



This message was scanned at Wednesday, January 18, 2012 3:00:34 AM GMT by Trend 
Micro IMHS on behalf of
White Clarke Group - www.whiteclarkegroup.com.

White Clarke Group Ltd - Registered in England - Registered number 03435619.
Registered address: Fairfax House, 15 Fulwood Place, London, WC1V 6AY 
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to