Format file path by adding datetime segment if necessary.
Append the last modified timestamp to the file name in the form of [file_name]?v=[timestamp].
Add the extention using composer:
"almeyda/fileversion": "*"
<link rel="stylesheet" type="text/css" href="<?php echo \almeyda\fileversion\src\FileVersion::set('pathToCssFileFromTheRoot'); ?>">
<img src="<?php echo \almeyda\fileversion\src\FileVersion::set('pathToImgFileFromTheRoot'); ?>">
<script src="<?php echo \almeyda\fileversion\src\FileVersion::set('pathToJsFileFromTheRoot'); ?>"></script>