Converting Date to Number and then back to Date

I recently implemented a delete file solution in witch I wanted to preserve the file in a trash folder, so I could eventually restore the file. Instead of deleting the file I renamed it and move it to the trash folder. Since a file with the same name could be re-created and then re-deleted, I wanted to make sure that I can preserve all the different versions of the file and and allow restoring any of the previously deleted version.

The solution that I implemented required to add a suffix to the name of the file using the current date and time as a number. Later on I can present a list of the files in the trash folder and convert the date-suffix back to the date and time when the file was deleted, allowing users to choose which version they want to restore.

Leave a Reply