w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
PowerShell Read file Modified Date and check if it was modified in the last X hours

a one liner :

if ( ((get-date) - (ls d:somefile).LastWriteTime).days -lt
1){echo "recently modified"}

to you second question :

$diff=((ls d:somefile).LastWriteTime - (get-date)).totalseconds
 if ($diff -gt -5) {echo "recent"}

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.