問題
整理照片時(shí),發(fā)現(xiàn)一些照片和視頻的拍攝時(shí)間不正確,年份都不對(duì),可能是由于上傳到云服務(wù)器再下載導(dǎo)致的,也有可能是一些照片處理軟件把時(shí)間改錯(cuò)了。怎么找到正確的時(shí)間?
有的手機(jī)把照片的文件名根據(jù)時(shí)間來命名,還好說,比如IMG_20180924_111456.jpg,按照這個(gè)文件名修改拍照時(shí)間即可。但是有的命名很奇怪,比如wx_camera_1537762382708.mp4,這長(zhǎng)串?dāng)?shù)字是什么?跟時(shí)間有關(guān)嗎?
解決方案
猜測(cè)是否跟Unix Time有關(guān),在命令行用python測(cè)試了下
PS C:\Users\xzhu> python -i
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> time.localtime(1537762382708)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 22] Invalid argument
>>>
數(shù)字太長(zhǎng)了?裁剪下呢?
>>> time.localtime(153776238270)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 22] Invalid argument
>>> time.localtime(15377623827)
time.struct_time(tm_year=2457, tm_mon=4, tm_mday=19, tm_hour=2, tm_min=10, tm_sec=27, tm_wday=3, tm_yday=109, tm_isdst=0)
不出錯(cuò)了,但是時(shí)間不對(duì),再刪一位
>>> time.localtime(1537762382)
time.struct_time(tm_year=2018, tm_mon=9, tm_mday=24, tm_hour=12, tm_min=13, tm_sec=2, tm_wday=0, tm_yday=267, tm_isdst=0)
正確了
總結(jié)
文件名前10位是Unix Time,可以轉(zhuǎn)換成年月日,沒有安裝python的話,網(wǎng)上有很多網(wǎng)站可以實(shí)時(shí)轉(zhuǎn)換