一般項目版本較多時,可以存入以版本号或時間命名的檔案夾。linux取時間的方法比較多,寫一個個人覺得比較好用的
(C++/C)
#include <stdio.h>
#include <time>
time_t now;
struct tm time_now;
now = time(NULL);
localtime_r(&now, &time_now);
char entire[30];
strftime(entire, 30, "%Y.%B%d.%H%M", &time_now);
std::cout<<entire<<std::endl;
結果為: 2011.February14.1619
補個tm的結構:
struct tm
{
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
};
傳回的字元串可以依下列的格式而定:
%a 星期幾的縮寫。
%A 星期幾的全名。
%b 月份名稱的縮寫。
%B 月份名稱的全名。
%c 本地端日期時間較佳表示字元串。
%d 用數字表示本月的第幾天 (範圍為 00 至 31)。日期
%H 用 24 小時制數字表示小時數 (範圍為 00 至 23)。
%I 用 12 小時制數字表示小時數 (範圍為 01 至 12)。
%j 以數字表示當年度的第幾天 (範圍為 001 至 366)。
%m 月份的數字 (範圍由 1 至 12)。
%M 分鐘。
%p 以 ''AM'' 或 ''PM'' 表示本地端時間。
%S 秒數。
%U 數字表示為本年度的第幾周,第一個星期由第一個周日開始。
%W 數字表示為本年度的第幾周,第一個星期由第一個周一開始。
%w 用數字表示本周的第幾天 ( 0 為周日)。
%x 不含時間的日期表示法。
%X 不含日期的時間表示法。
%y 二位數字表示年份 (範圍由 00 至 99)。
%Y 完整的年份數字表示,即四位數。
%Z(%z) 時區或名稱縮寫。
%% % 字元。