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

  • Thread starter Thread starter Mark Poppers
  • Start date Start date
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
 
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
 
string myTime = DateTime.Now.ToString("yyyy.MM.dd
HH:mm:ss:ffff");
Console.WriteLine(myTime);

Mark Poppers je napisao/la:
 
Back
Top