for /f %%a in (time.txt) do (set k=%%a)
echo,%k%
for /f "delims=" %%i in ('powershell -c "((Get-Date)-(Get-Date %k%)).Days"') do (set d=%%i)
echo,%d%
pause
结果如下:
C:\Users\solan\Desktop>for /F %a in (time.txt) do (set k=%a )
C:\Users\solan\Desktop>(set k=2016/09/18 )
C:\Users\solan\Desktop>echo,2016/09/18
2016/09/18
C:\Users\solan\Desktop>for /F "delims=" %i in ('powershell -c "((Get-Date)-(Get-Date 2016/09/18)).Days"') do (set d=%i )