Open Closed

Handling UTC time for saving and searching data #9062

razkhan78 created

We have some scenario in our app for UTC DateTime

  1. Right now when we storing the date value with AuditedEntity in the table it always stores dates with a local provider,

For that we found some details to set clock provider to UTC but for the same, we have 2 more queries:

1)When we select datepicker from the front side we need to store that Datepciker date to UTC DateTime in the table, Is there any way for that? 2)Consider that in the table we have all the DateTime in the UTC format, now the user came to our app and search via local date, then how we can search date with UTC DateTime in the table?

1 Answer(s)
  • 0
    ismcagdas created
    Support Team

    Hi @razkhan78

    1. When you use UtcClockProvider, AspNet Zero automatically converts all dates sent from client to server to UTC.
    2. Same as 1, when client posts the search date to server, date will be converted to UTC and you can just use a repository to query the database with the date field sent from client.