Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 455881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:24:56+00:00 2026-05-12T22:24:56+00:00

I assume this should be pretty simple, but could not get it :(. In

  • 0

I assume this should be pretty simple, but could not get it :(.
In this format Z is time zone.

T is long time pattern

How could I get a date in this format except by using

DateTime dt = DateTime.Now;
Console.WriteLine(dt.ToString("yyyy-MM-ddTHH:mm:ssZ"));

in C#

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T22:24:57+00:00Added an answer on May 12, 2026 at 10:24 pm

    Using UTC

    ISO 8601 (MSDN datetime formats)

    Console.WriteLine(DateTime.UtcNow.ToString("s") + "Z");
    

    2009-11-13T10:39:35Z

    The Z is there because

    If the time is in UTC, add a ‘Z’
    directly after the time without a
    space. ‘Z’ is the zone designator for
    the zero UTC offset. “09:30 UTC” is
    therefore represented as “09:30Z” or
    “0930Z”. “14:45:15 UTC” would be
    “14:45:15Z” or “144515Z”.

    If you want to include an offset

    int hours = TimeZoneInfo.Local.BaseUtcOffset.Hours;
    string offset = string.Format("{0}{1}",((hours >0)? "+" :""),hours.ToString("00"));
    string isoformat = DateTime.Now.ToString("s") + offset;
    Console.WriteLine(isoformat);
    

    Two things to note: + or – is needed after the time but obviously + doesn’t show on positive numbers. According to wikipedia the offset can be in +hh format or +hh:mm. I’ve kept to just hours.

    As far as I know, RFC1123 (HTTP date, the “u” formatter) isn’t meant to give time zone offsets. All times are intended to be GMT/UTC.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote this snippet of code and I assume len is tail-recursive, but a
This is a bit hypothetical and grossly simplified but... Assume a program that will
On OS from win 2000 or later (any language) can I assume that this
Lets assume we have this xml: <?xml version=1.0 encoding=UTF-8?> <tns:RegistryResponse status=urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Failure xmlns:tns=urn:oasis:names:tc:ebxml-regrep:xsd:rs:3.0 xmlns:rim=urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0> <tns:RegistryErrorList
Assume I have a function template like this: template<class T> inline void doStuff(T* arr)
Assume we have a method like this: public IEnumerable<T> FirstMethod() { var entities =
This is an Eclipse question, and you can assume the Java package for all
This is one of those little detail (and possibly religious) questions. Let's assume we're
Assume java 1.6 and leopard. Ideally, it would also be nice to get a
I'm learning C++ and can't get my head around this problem: I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.