Share via

Database DateTime not the same as Label

Adrian N 81 Reputation points
2021-03-26T00:59:31.63+00:00

Hi Everyone I have an issue where I insert the correct DateTime in the database. But it won't come out as the same DateTime when I Bind it to a Label. The DateTime that's in the database is: 2021-03-26 09:51:57.887 However, when I Bind that same column within my Xamarin Forms Application, it comes out as: 26/03/2021 19:03 This is the xaml code I used: <Label Text="{Binding QuoteDate, StringFormat='{0:dd/MM/yyyy HH:MM}'}" /> Just wondering if it's because I haven't set my emulator device correctly or a setting within the Azure Database. Thanks for help!

Developer technologies | .NET | Xamarin

1 answer

Sort by: Most helpful
  1. Adrian N 81 Reputation points
    2021-03-27T07:15:08.237+00:00

    Thanks for the reply @Anonymous !

    I couldn't find the settings to change the Time Zone for the SQL Database however, reading through some docs I found I couldn't??
    https://techcommunity.microsoft.com/t5/azure-database-support-blog/lesson-learned-4-modifying-the-default-time-zone-for-your-local/ba-p/368798

    On the other hand, the time that is being written into the database is correct. I've configured the application to write the DateTime as AEST using TimeZoneInfo and that works great.
    But when the emulator is reading it. It returns as a completely different Time.

    The configuration on my emulator is set to use AEST as well. So I'm not 100% sure where and why it's changing the DateTime when I view the object within my app.

    81959-emulator-datetime.png

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.