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 1074687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:09:54+00:00 2026-05-16T21:09:54+00:00

I dont get following desired output from a DateTime-Object: 2010-03-29 13:15:00 My default localization

  • 0

I dont get following desired output from a DateTime-Object:

2010-03-29 13:15:00

My default localization is de-DE, so a simple ToString gives me:

29.03.2010 13:15:00

What I’ve tried is to create a DateTimeFormatInfo Object from US-Culture and use its DateTimePatterns but without success:

Dim usDateFormat As Globalization.DateTimeFormatInfo = New Globalization.CultureInfo("en-US", False).DateTimeFormat
usDateFormat.DateSeparator = "-"
ruleResult.Claim.Last_Updated_Date.ToString(usDateFormat.ShortDatePattern)

Output: 3.29.2010

What is the best way (readable,fastest) to get my desired DateTimeFormat(i need sometimes the short Date and sometimes the Date and Time like in my example above)?

Thanking you in anticipation,
Tim

EDIT: why does my DateTimeFormatInfo approach not work and makes it a performance difference when using the String.Format or ToString(“yyyy-MM-dd HH:mm:ss”) solutions instead of a private shared(static) DateTimeFormatInfo-Object? I’m calling this function at least 30k times and there are many Dates to format inside.

  • 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-16T21:09:54+00:00Added an answer on May 16, 2026 at 9:09 pm

    I think what you are looking for is:

    DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
    

    Here are some examples, I think if look at then you can understand how it works:

    // create date time 2008-03-09 16:05:07.123
    DateTime dateTime = new DateTime(2008, 3, 9, 16, 5, 7, 123);
    
    dateTime.ToString("y yy yyy yyyy");  // "8 08 008 2008"   year
    dateTime.ToString("M MM MMM MMMM");  // "3 03 Mar March"  month
    dateTime.ToString("d dd ddd dddd");  // "9 09 Sun Sunday" day
    dateTime.ToString("h hh H HH"    );  // "4 04 16 16"      hour 12/24
    dateTime.ToString("m mm"         );  // "5 05"            minute
    dateTime.ToString("s ss"         );  // "7 07"            second
    dateTime.ToString("f ff fff ffff");  // "1 12 123 1230"   sec.fraction
    dateTime.ToString("F FF FFF FFFF");  // "1 12 123 123"    without zeroes
    dateTime.ToString("t tt"         );  // "P PM"            A.M. or P.M.
    dateTime.ToString("z zz zzz"     );  // "-6 -06 -06:00"   time zone
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to output the following table from my database DateTime | Measure
When I type the following into the interpreter I get the desired output behavior:
I tried the following code. Although I don't get any errors, it did not
I dont get why this simple line of code does not work: <?php $someVariable
Ok... I tried google and didn't get many hits. I dont want to abuse
I get following text from the as a result of a AJAX request. <div
In perl 5.8.5, if I do the following, I don't get an error: use
I still dont get it, which color will be paragraph test1 and why? <style>
I don't understand: In android, I dont get the full string returned I entered
I want to do some innerHTML replacements, but using PHP includes, I dont get

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.