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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:28:21+00:00 2026-05-22T23:28:21+00:00

I am trying to create a string to show the current date and time

  • 0

I am trying to create a string to show the current date and time without wanting to use any slashes just the numbers.

For example, 09 jun 2011 11AM should be 201109061100

But when i run the below code the time is always 0000

Output:

ResultLog201109060000

Code:

DateTime currDate = DateTime.Today;
String resultlogFilename;
resultlogFilename = 
    "ResultLog" + 
    currDate.ToString("yyyy") + 
    currDate.ToString("dd") + 
    currDate.ToString("MM") + 
    currDate.ToString("HH") + 
    currDate.ToString("mm");

Any idea how to get the correct time?

  • 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-22T23:28:22+00:00Added an answer on May 22, 2026 at 11:28 pm

    DateTime.Today seems to return the Date part not the hour part.

    Just use DateTime.Now to get a complete time.

    http://msdn.microsoft.com/en-us/library/system.datetime.now.aspx

    Msdn DateTime.Today

    Because it returns the current date without the current time, the Today property is suitable for use in applications that work with dates only. For details, see Choosing Between DateTime, DateTimeOffset, and TimeZoneInfo. In contrast, the TimeOfDay property returns the current time without the current date, and the Now property returns both the current date and the current time.

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

Sidebar

Related Questions

I'm trying to dynamically create a connection string during compile time: private static string
I'm trying to create a regex to tokenize a string. An example of the
Im trying to create a C based string menu where a user inputs a
I'm trying to create a dictionary type - ie hash table with a string
I'm trying to learn bash string handling. How do I create a bash script
So i'm trying to POST something to a webserver. System.Net.HttpWebRequest EventReq = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(url); System.String
I am trying to create a program which will show me the status of
I'm trying to create a JTable with 2 columns, one must show the name
I'm trying to create Preference Screen with a Checkbox control. <CheckBoxPreference android:summaryOn=@string/mySummaryOn android:summaryOff=@string/mySummaryOff android:key=myCB
I am trying to create a URL friendly link from a string. Instead of

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.