Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Datetime.Today in GMT in c#

I want to convert DateTime.Today to GMT time.

i.e. If I am in L.A. and it is 11pm of 22/02/2012 I want DateTime.Today to be 23/02/2012 because it will be that day in GMT time.

like image 336
Tony Avatar asked May 29 '12 15:05

Tony


People also ask

What is UtcNow ()?

The function utcNow() returns a DateTime in the format of: 2019-07-25T21:48:02Z which is equivalent to: “yyyy-MM-ddTHH:mm:ssZ”. We can reformat this in flow by doing the following: The above example shows one way of formatting the date time to a date only.

Is DateTime today in UTC?

it is not correct unless midnight in local time ( date. today() ) is the same time instance as midnight in UTC ( . utcnow().

What is GMT format?

GMT is a time zone officially used in some European and African countries. The time can be displayed using both the 24-hour format (0 - 24) or the 12-hour format (1 - 12 am/pm). UTC is not a time zone, but a time standard that is the basis for civil time and time zones worldwide.

How do I use DateTime UtcNow?

An alternative to using UtcNow is DateTimeOffset. UtcNow. While the former indicates that a date and time value is Coordinated Universal Time (UTC) by assigning DateTimeKind. Utc to its Kind property, the latter assigns the date and time value the UTC time's offset (equal to TimeSpan.


1 Answers

There is no DateTime.UtcToday, but you can try DateTime.UtcNow.Date

like image 189
Carsten Schütte Avatar answered Oct 20 '22 14:10

Carsten Schütte