Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set the date and time for a file

Tags:

date

file

php

time

I want to add date and time on an image file that I have uploaded. Which way is the best to accomplish this?

Thanks in advance!

like image 666
Airikr Avatar asked Mar 01 '12 00:03

Airikr


People also ask

How can I change the date and time of a file?

Right-click the current time and select the option to "Adjust Date/Time." Choose the option to "Change Date and Time..." and input the new information in the time and date fields. Press "OK" to save your changes and then open the file you want to change.

Can you change the timestamp of a file?

If you ever want to quickly update the Modified time stamp of a file to the current day and time, right-click that file, select Properties, select the TimeStamps tab, and then click the Touch button. That will instantly change the Last modified entry to the current day and time.

Can I change the date modified on a file?

Unfortunately it's not possible to manually change the modified date of any file in Windows.


1 Answers

You can use the touch function to set the last modified date:

touch("path/to/my-image-file.jpg", $someTimestamp);

To retrieve this in PHP, use filemtime.

like image 172
Ry- Avatar answered Oct 06 '22 01:10

Ry-