Comparing different time formats

I am trying to do a comparison of files based on their last modified date.

I am pulling the first file from a webapp folder using curl.

curl --silent -I http://localhost:8023/conf/log4j2.xml | grep Last
Last-Modified: Tue, 22 Mar 2016 22:02:18 GMT

The second file is on local disk.

stat /var/tmp/log4j2.xml  | grep Modify | awk '{print $2" "$3}' | cut -d'.' -f1
2016-03-24 13:56:51

Is there a mechanism to convert the times ? So that I can then compare the two times and take an action accordingly.

Hi.

To what granularity? Same year? Same month? Day? Hour?, etc.

Best wishes ... cheers, drl

1 Like

Day Month Hour Minute

I found something like this which gives me the same format. Thats what I needed.

    OLD=`date --date="$OLD_TIME"`
    NEW=`date --date="$NEW_TIME"`