Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
根据 sqlite3 手册,它说格式应该是YYYY-DD-MM。 如果我有一个 842、2、4 的变量,以及如何转换成相同的格式?
我尝试了strftime和date这两个函数,但如果数字是单个,它不会填充值“0”。
例子:
'842-2-4'
需要转换为
'0842-02-04'.
int yyyy = 842; int dd = 2; int mm = 4; char buf[11]; sprintf(buf,"%04d-%02d-%02d",yyyy,dd,mm);