功能:實(shí)現(xiàn)寫入時(shí)間到sqlite數(shù)據(jù)庫(kù),精確到毫秒
錯(cuò)誤寫法
DateTime.Now.ToString();
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff");
正確寫法:
DateTime.Now.ToString("s");//轉(zhuǎn)換成帶T形式
DateTime.ToString("yyyy-MM-ddTHH:mm:ss.fff");//需要加T字符且后面的毫秒時(shí)間要用.號(hào)
PS:查詢數(shù)據(jù)庫(kù)時(shí)要用strftime函數(shù)格式化才能獲取毫秒時(shí)間
類似:select *,strftime(time) as datetime from test

image.png