开发者

Get local time in 24hr format

I know this is a rather under-level question, if you may, but I'm having some trouble looking for code that I can put in my Windows forms. I just have three mere requirements:

  • I need the local time, which is EDT.
  • I also need the time in 24-hour format so it's easier to read.
  • Where to put the code in m开发者_开发技巧y Windows forms?


Since you've tagged your question with 'winforms' I'm assuming you're running on the .NET Framework. If so, I suggest starting here:

Coding Best Practices Using DateTime in the .NET Framework

... and also checking the documentation on DateTIme formatting here:

Custom Date and Time Format Strings


/* localtime example */
#include <stdio.h>
#include <time.h>

int main ()
{
  time_t rawtime;
  struct tm * timeinfo;

  time ( &rawtime );
  timeinfo = localtime ( &rawtime );
  printf ( "Current local time and date: %s", asctime (timeinfo) );

 return 0;
}

http://www.cplusplus.com/reference/clibrary/ctime/localtime/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜