Home Ask Login Register

Developers Planet

Your answer is one click away!

M21 February 2016

PHP generate PNG with dynamic date

I'm looking to generate a .png image with a dynamic date, ex:

take today's date +7 days and create a .png that displays that date.

I'd like to keep the .png name the same and just overwrite once a week, always showing the date + 7 from that one day a week.


Is this possible?


cteski February 2016

Yes, the GD library can create images and it is possible to write text to the image using functions such as imagestring or imagettftext.

Nathan February 2016

Imagemagick can do this fairly easily and is easy to have it run as a cronjob for automatic generation.

Mark Setchell February 2016

If you have the GNU date command, you can get the date 7 days from now with:

date -d '+7 days'

You could then pump that, or whatever parts of it you want into the script in my other answer here.

You don't say how you want it formatted, but that script comes up like this:

enter image description here

Post Status

Asked in February 2016
Viewed 2,732 times
Voted 8
Answered 3 times


Leave an answer

Quote of the day: live life