How can i get the device date time?

I have a issue.

When I change the device date time and run the App, the code DateTime.Now don't return the new date, it returns the old date.
How can I get the device date time?



  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    Are you REALLY sure?

  • CarlosAyalaCarlosAyala Member ✭✭

    @AlessandroCaliaro yes, sure. I thinks the Xamarin get the timezone, not the device date time. I need the device time.

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    Never seen such a thing. I'm with @AlessandroCaliaro in disbelief.

  • CarlosAyalaCarlosAyala Member ✭✭

    Tested several times. I reboot the device and nothing happens, the DateTime.Now dont take the device date time.

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭
    edited May 2018

    Then you're probably the only person with that happening... anywhere.
    I have a solution out there in 20,000 vehicles across all USA timezones. If didn't work, I'd have heard about it long ago.

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    Are you sure you have not "Automatic date time" set?

  • JamesLaveryJamesLavery GBBeta, University ✭✭✭✭✭
    Please give a full example of what you are seeing and what you are expecting.

    It sounds to me that the code is returning UTC and you are expecting local time. Or as Alessandro says, automatic date time settings are resetting the time.
  • hverma11hverma11 Member ✭✭

    I am also facing the same issue:

    DateTime StartDate = DateTime.Now; // Today is 12/10/2018 but returning 11/10/2018

  • hverma11hverma11 Member ✭✭

    I missed, it is Emulator not your local machine i.e. DateTime of Emulator. All good...

Sign In or Register to comment.