Need to format a date!

  • Thread starter Thread starter Jens Jensen
  • Start date Start date
J

Jens Jensen

Hello,
I need to format the current date in C# so it looks like this:
10/4/2006 1:38:53 PM



Can somen tell how i do this?





Many thanks

JJ
 
DateTime.Now.ToString(); by default will give you that format.
- or -
DateTime.Now.ToString("G"); for general formatting.
 
Jens,

Is this in your current culture setting, maybe is it better to show it next
time in dd/MM/yyyy hh:mm:ss aa
Or to use a date as 31 december, now we cannot see if you want to use it for
the USA or for the rest of the English speaking cultures in the world.

Cor
 
Jens,

I see now that you are Danish, in our cultures the am/pm is not used, AFAIK
have you first to change the culture to an English one
(threading.currentthread.currentculture) and that as I wrote in my previous
message depending where the month has to be (in USA or other English
cultures way) or use the ICultureProvider. I thought that Danmark was as
well using a 24 hour clock.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top