In node-red how to get the file last modified timestamp

In node-red as watch node will be triggered for modification I'm trying to get the last file modified time, but is there any node to get the file last modified time.

If you are using a watch node then the last modified time is now.

No to solve watch node problem only i'm using file last modified time. Is there any node or how to get that.

If you can't find one serching the flows library why not write one?

Yeah i can write in function but I am using node-red snap. So, for using any module I have to edit settings.js to add that library, But in node-red snap I didnt found settings.js.

for reading I wrote the below function but it is giving following exception

fs.stat("/dir/file.txt", function(err, stats){
    var mtime = new Date(util.inspect(stats.mtime));
    console.log(mtime);
});

ReferenceError: fs is not defined (line 1, col 13)

What platform and OS are you running on?
Why not follow the directions here Getting Started : Node-RED ?

I've never seen SNAP till you mentioned it, but settings.js should be in the .node-red folder (ina normal install)

answered in another thread - In node-red snap how to change the settings.js file

What watch node problem? If you mean the fact that you only want one message as in the other thread then you can do that much easier than looking at the last modified time by using a Trigger node as I suggested. It is trivially easy.

But watch node will trigger if content is not saved(i mean even if you try to modify it'll trigger), but I want trigger only when the content is changed(i mean saved).

In what way do you mean 'try to modify' that does not actually modify it?

I used shell scripting in node-red for getting last modified date and time.
script: date -r <filename>

You never explained why the watch node would not do the job.

In linux if the user doesnt have have permission but if he tries to modify then also the last modified date changes so watch node will also be trigerred. But I wanted that the trigger should come once the content in file changes.

So I used variable for storing the content and for comparison, as the content is from gpio it will be either 0 or 1 but the trigger will be from watch node only(if watch node triggers also, i am checking whether the content is changing or not ). I have not used last modified date as solution but I tried to answer as it may help some one and they dont have to include any library.

If you are writing the gpio state to a file then reading it back somewhere else, have you considered using MQTT to send the value? That would be the usual way to do that, unless you have an unusual requirement.

Yeah I am sending to mqtt

Why are you reading it from a file then?