Search code examples
datetimeasp.net-mvc-4simplemembershipiis-8sql-server-2012-express

When WebSecurity fails a login, it stores the LastPasswordFailureDate as being wrong by 11 hours


It's currently 12:56am, 29/3/2013 (Australia).

When I get a username/password combination wrong, the database reports that the last login failure is

2013-03-28 13:56:18.517

It's behind by 11 hours. I'm using out-of-the-box WebSecurity and SimpleMembershipProvider.

A SELECT GETDATE() in SQL Server 2012 says 2013-03-29 00:58:40.930. It's fine.

What's happening?


Solution

  • I believe that it stores the date as a Coordinated Universal Time (DateTime.UtcNow()). This would explain why you are off by that amount.

    One example of why this is a good thing as if you were to share databases/servers across time zones (think load balancing) - your DateTime entries would stay 'synced'.

    More Information from MSDN on UTC time / DateTime functions