How to change the TimeStamp using RUBY

For Changing the TimeStamp we are going to use touch
FileUtils.touch 'sample.txt', :mtime => Time.now - 2.hours
If you omit the :mtime the modification timestamp will be set to the current time:
FileUtils.touch 'sample.txt'
You may also pass an array of filenames:
FileUtils.touch %w[ foo bar baz ], :mtime => Time.now - 2.hours

Non-existent files will be created.

Comments

Popular posts from this blog

Inserting and Moving elements inside Ruby Array

Remove duplicates from a JavaScript Array

Sending Binary Data over the Network with Json