Version: v6.10.3 Platform: Windows 10 64-bit Subsystem: fs Disk format: NTFS This issue is related to #13255 . ```javascript let fs = require('fs'); let src = 'path/to/src'; let src_stats = fs.statSync(src); let dest = 'path/to/dest' if (fs.existsSync(dest)) { fs.utimesSync(dest, src_stats.atime, src_stats.mtime); } let dest_stats = fs.statSync(dest); console.log(src_stats.mtime); console.log(dest_stats.mtime); console.log(src_stats.mtime == dest_stats.mtime); ``` output: ``` 2017-05-11T06:35:33.501Z 2017-05-11T06:35:33.000Z false ``` So the millisecond part of `mtime` is discarded when setting the time but not when getting the time. Why is this inconsistent?
Activity
[-]fs.utimes truncated[/-][+]fs.utimes set truncated date[/+][-]fs.utimes set truncated date[/-][+]fs.utimes truncate date[/+]duanyao commentedon Jul 10, 2017
I confirm that this issue also happen on Linux 4.9.29, X86-64, with ext4 fs, node v6.10.2.
The workaround is using fs.futimes{Sync} instead.
bnoordhuis commentedon Jul 10, 2017
@refack Was this fixed by #13281?
refack commentedon Jul 10, 2017
I'll test, but FWIW if the issue is not inthe issue is inutimesSyncwe also have #13173utimes/utimesSyncrefack commentedon Jul 10, 2017
So, fixed on windows:
Broken on WSL (so assuming Ubuntu)
refael@refaelux:/mnt/d/code/node$ node ../4node/test-utime-truncation.js 2017-07-10T14:20:16.103Z 2017-07-10T14:20:16.000Z false refael@refaelux:/mnt/d/code/node$ node -v v9.0.0-nightly2017070918069523f8[edit]
😕 But the docs say the times need to be integers in seconds - https://nodejs.org/api/fs.html#fs_fs_utimes_path_atime_mtime_callback
test-utime-truncation.js
refack commentedon Jul 10, 2017
PR to improve docs #14154
bnoordhuis commentedon Sep 29, 2017
@refack Can this be closed?
refack commentedon Sep 29, 2017
Fixed by 64e97b2