1

is there any extension i can use to convert/display my DateTimeOffset type property to Zulu time in razor (cshtml file)? example:

DateTimeOffset = 1028 -----> Zulu = 1428

none of the ToString extension can convert to zulu. example below

myDate.ToString("t")

i like to know if i have to make a converter, or if there's an easier way to do in razor

maccettura
  • 10,514
  • 3
  • 28
  • 35
Dnguy025
  • 93
  • 1
  • 10
  • [`DateTime.ToUniversalTime()` Method](https://msdn.microsoft.com/en-us/library/system.datetime.touniversaltime(v=vs.110).aspx) – Robert Harvey Apr 25 '18 at 20:11
  • @RobertHarvey im assuming there's more to that, because if just that did not convert to zulu – Dnguy025 Apr 25 '18 at 20:18
  • Well, you have to read the article I linked. There are some flags you may have to set properly. – Robert Harvey Apr 25 '18 at 20:19
  • If I understand your question properly it may be answered here: https://stackoverflow.com/questions/1820915/how-can-i-format-datetime-to-web-utc-format – Casper-Evil Apr 25 '18 at 20:23

2 Answers2

0

If you want to display something in zulu time, you can do .ToString("u"). This will give you something like this: "2020-02-24 19:17:12Z"

-2

turns out Zulu time is 4 hours ahead of DateTimeOffSet time. and it is equivalent to UtcDateTime. So all i had to do was

myDate.UtcDateTime.Tostring("t")
Dnguy025
  • 93
  • 1
  • 10