Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

DateTimeElemement returning the wrong time

$
0
0

Hi All,

A day lost to this one, really cannot figure out what is going wrong, using MT.D it does not matter if I use DateTimeElement or NullableDateTimeElement, when I set the current date using again it does not matter which one either fails

_elNextSchedule.Value = DateTime.Now;

or

_elNextSchedule.DateValue = DateTime.Now;

the date and time goes in ok and shows correctly in the picker, when I come back out the hour has slipped by an hour,

all I need is a very simple example of how to properly set the date and time from my database record (which has the right information) and then for it to update it correctly without the hour slippage.

TBH I have tried so many things like the following to set up formatting.

Core.Instance.fmtDateTime = new NSDateFormatter();
Core.Instance.fmtDateTime.DateStyle = NSDateFormatterStyle.Short;

Core.Instance.dateFormat = "dd/MM/yyyy";
Core.Instance.timeFormat = "hh:mm tt";
Core.Instance.dateTimeFormat = "dd/MM/yyyy hh:mm tt";

to initialise the element

_elNextSchedule = new DateTimeElement("Schedule date", p2p.next_schedule.Value);
_elNextSchedule.DateValue = p2p.next_schedule.Value.ToLocalTime();
_elNextSchedule.fmt = Core.Instance.fmtDateTime;

to write the information back to the database

p2p.next_schedule = _elNextSchedule.DateValue;

p2p.next_schedule = _elNextSchedule.DateValue.ToLocalTime();

I am in the UK and it feels like an issue with clocks going forward and backward and time.

there must be a simple way to set this.

thanks.

Alex


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>