开发者

Custom Format for Current Date and Time in C++

I am trying to save a file into a directory of files ba开发者_开发百科sed on the current date and time. I am trying to get the format of the following:

  1. "FullMonth-FullYear" example: "April-2011"

  2. "FullMonth-littleDay-year" example: "March-7-11"
  3. hour-minutes-seconds. example: "18:05:09" in 24 hour format


It depends on the format you have the time in right now. I'm a big fan of sprintf(), and since I mostly deal with big piles of seconds, milliseconds, or nanoseconds, I do a lot of modulus arithmetic to get what I want.


boost.date_time can do arbitrary formatting, to a higher a degree of precision than the standard functions are typically capable of. Specifically, see Date Time Input/Output Format Flags.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜