Expiry date on a certificate. Please Help

Expiry date on a certificate. Please Help

by John Graham -
Number of replies: 2

Recently I have added the Certificate module to our Moodle Site 2.3.2+ (Build: 20120927). I have used tips from this forum to modify my certificate, text, design etc, and works great! Instead of having the date on the certificate I would like to have an expiry date.  So if the certificate was issued today the expiry date would be 04 October 2013.

Now when looking through this forum someone has posted this code, which I added to certificate/type/my certificate/certificate.php:


$expdate = str_replace(' 0', ' ', strftime('%B %d, %Y',(strtotime("+2 years", $certdate))));
cert_printtext(285, 480, 'C', 'Arial', '', 16, utf8_decode("Expiration Date: ".$expdate));

That did not work so I changed the code to this:

$expdate = str_replace(' 0', ' ', strftime('%B %d, %Y',(strtotime("+1 years", $prereq_date))));

certificate_print_text($pdf, $x, $y, + 98, 'Helvetica', '', 16, utf8_decode("Expiration Date: ".$expdate));

The expiry date now shows on the certificate but as ‘Expiration Date: January 1, 1971’. I am not a programmer but I have experience with HTML/CSS.

Any ideas?

 

Thanks

John

Average of ratings: Useful (1)
In reply to John Graham

Re: Expiry date on a certificate. Please Help

by Mark Nelson -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi John,

I would actually do something like the following (I haven't test it).

$timetoadd = 365 * 24 * 60 * 60; // A year in seconds
$expdate = $certrecord->timecreated + $timetoadd;

certificate_print_text($pdf, $x, $y, + 98, 'Helvetica', '', 16, "Expiration Date: " . date("F d, Y", $expdate));

Regards,

Mark

Average of ratings: Useful (1)
In reply to Mark Nelson

Re: Expiry date on a certificate. Please Help

by John Graham -

Thanks Mark that worked!

Cheers for the help