[fs.op.last.write.time]

# 31 Input/output library [[input.output]](./#input.output)

## 31.12 File systems [[filesystems]](filesystems#fs.op.last.write.time)

### 31.12.13 Filesystem operation functions [[fs.op.funcs]](fs.op.funcs#fs.op.last.write.time)

#### 31.12.13.26 Last write time [fs.op.last.write.time]

[ð](#lib:last_write_time)

`file_time_type filesystem::last_write_time(const path& p);
file_time_type filesystem::last_write_time(const path& p, error_code& ec) noexcept;
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L18247)

*Returns*: The time of last data modification of p,
 determined as if by the value of the POSIX stat class member st_mtime obtained as if by POSIX stat[.](#1.sentence-1)

The signature with argument ec returns file_time_type​::​min() if an error occurs[.](#1.sentence-2)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L18255)

*Throws*: As specified in [[fs.err.report]](fs.err.report "31.12.5 Error reporting")[.](#2.sentence-1)

[ð](#lib:last_write_time_)

`void filesystem::last_write_time(const path& p, file_time_type new_time);
void filesystem::last_write_time(const path& p, file_time_type new_time,
                     error_code& ec) noexcept;
`

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L18268)

*Effects*: Sets the time of last data modification of the file
 resolved to by p to new_time, as if by POSIX [futimens](http://pubs.opengroup.org/onlinepubs/9699919799/functions/futimens.html)[.](#3.sentence-1)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L18273)

*Throws*: As specified in [[fs.err.report]](fs.err.report "31.12.5 Error reporting")[.](#4.sentence-1)

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L18277)

[*Note [1](#note-1)*:

A postcondition of last_write_time(p) == new_time is not specified
because it does not necessarily hold for file systems with coarse time granularity[.](#5.sentence-1)

â *end note*]
