1

I am making a game off Ubuntu through the terminal and one feature I would like to add is adding timestamps to the saved games.

Like the game would display "Save: (time)" and in time would be (DD/MM/YYYY HH:MM) is there a simple way to do this?

4

1 回答 1

1

为了获取当前日期,您可以使用命令date。有关man date更多格式选项,请参阅。

$ date +'%d/%m/%y %T'
26/10/13 16:29:56

如果您想从 C++ 计算时间戳,请查看如何获取本地时间并将其放入字符串中。

于 2013-10-26T14:31:54.230 回答