Getting the current time and format it to an own format ?

M

Mark Poppers

I would like to get the current time(stamp) (including the milliseconds)
and assign it into a string variable with a format like:

xxxx mytime = getcurrentsystemtime();
string mytime = reformatto("yyy.mm.dd HH:MM:SS:MSMS", mytime);

How do I do this ? The hours should be displayed in 24h mode

Mark
 
M

Moty Michaely

I would like to get the current time(stamp) (including the milliseconds)
and assign it into a string variable with a format like:

xxxx mytime = getcurrentsystemtime();
string mytime = reformatto("yyy.mm.dd HH:MM:SS:MSMS", mytime);

How do I do this ? The hours should be displayed in 24h mode

Mark

Dear Mark,

Use DateTime.Now.ToString() overloads to format the current system
time.

To Convert the current time to other datetime formats (such as UTC)
use the DateTime.Now.To* method family.

Hope this helps.
Moty
 
M

Miroslav Stampar

string myTime = DateTime.Now.ToString("yyyy.MM.dd
HH:mm:ss:ffff");
Console.WriteLine(myTime);

Mark Poppers je napisao/la:
 

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

Top