-4

I am using C#.net and Asp.net. I am trying to get the following format and assign that value into a TextBox. I am not sure how to accomplish. It has to be in this timestamp format: "YYYY-MM-DDTHH:MM:SS.0000000-00:00"

  • 1
    What do you mean by "get the following format"? It's very unclear what information you've already got, what you need, and what you've tried... – Jon Skeet Oct 28 '15 at 16:14
  • 1
    this question should help you figure out what you need. Scroll through all the answers. http://stackoverflow.com/questions/3025361/c-sharp-datetime-to-yyyymmddhhmmss-format – Adam Heeg Oct 28 '15 at 16:19
  • I have tryied using "DateTime thisDay = DateTime.Today;" Then I tried using the datetime.tostring method but getting the right outcome. – user3128770 Oct 28 '15 at 16:21
  • Adam Heeg thanks this will help me – user3128770 Oct 28 '15 at 16:22
  • It looks like the end -00:00 may be the difference from UTC and may need to be appended to the first part as a second string. – jdweng Oct 28 '15 at 16:25
  • 1
    Possible duplicate of [datetime to string with time zone](http://stackoverflow.com/questions/3323113/datetime-to-string-with-time-zone) – jmoerdyk Oct 28 '15 at 16:45

1 Answers1

2
DateTime.Now.ToString("o") + DateTime.Now.ToString("zzz");
GreatAndPowerfulOz
  • 1,767
  • 13
  • 19