SecretBeggining Posted April 13, 2011 Share Posted April 13, 2011 Hi everyone, complete beginner so I am sorry if this is posted in the wrong section. I find PHP very interesting and a lot easier than other programming languages to pick up (I've had issues trying to learn programming languages in the past). I currently have an old laptop running ubuntu 10.04 with Apache, PHP and MySQL installed. It all seems to be working well and together which is nice. I am currently learning the basics, reading and watching tutorials etc etc. I'm not sure if its a bit complex to start but I would like to learn how to write the current data and day of the week onto an image. Really appreciate you reading and if you post thats even better! Any ideas for tips for me would also be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/233624-displaying-current-date-on-an-image/ Share on other sites More sharing options...
betterphp Posted April 14, 2011 Share Posted April 14, 2011 Well if you are a beginner you have jumped in with somethign is a bit of a pain really. what you need to do is create an image resource form the file using somethign like imagecreatefrompng() then write on that image using either imagestring() or imagettftext(). Finally you need to output the image to either the screen or a file using somethign like imagejpeg() there are examples of all of those functions on their php.net pages. Quote Link to comment https://forums.phpfreaks.com/topic/233624-displaying-current-date-on-an-image/#findComment-1201791 Share on other sites More sharing options...
malinens Posted April 23, 2011 Share Posted April 23, 2011 Everyting can be found on php.net. I am programming in PHP for more than three years and I still very frequently use php.net manual. header("Content-Type: image/png"); ///dimensions $im = @imagecreate(110, 20) or die("Cannot Initialize new GD image stream"); $background_color = imagecolorallocate($im, 0, 0, 0); $text_color = imagecolorallocate($im, 233, 14, 91); //use date() function to get date Y- year, m- month, d- day, H- hour, i- minute, s- second //other date parameters can be found in http://www.php.net/manual/en/function.date.php $date = date("Y-m-d H:i:s"); imagestring($im, 1, 5, 5, "Date: $date", $text_color); imagepng($im); imagedestroy($im); Quote Link to comment https://forums.phpfreaks.com/topic/233624-displaying-current-date-on-an-image/#findComment-1205169 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.