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?
为了获取当前日期,您可以使用命令date。有关man date
更多格式选项,请参阅。
$ date +'%d/%m/%y %T'
26/10/13 16:29:56
如果您想从 C++ 计算时间戳,请查看如何获取本地时间并将其放入字符串中。