d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Php Barcode Date
Add Reply New Topic New Poll
Member
Posts: 18,138
Joined: May 31 2010
Gold: 7.27
Mar 21 2017 11:39am
I am trying to make a expiration date bar code. But i don't know if im using the right syntax and I cant find anything relating to what i'm doing..

Im adding 1 year to the have ready date of an item. The barcode gets made but doesnt contain any dates. even when I try to just display the variable on the html it shows up blank so its not setting the date.

Code

// Experation date code for case label bar code.

$oneYearFromNow = date("d/m/Y", strtotime + "365 days", strtotime($myOrd->hr_date));

$barcode = "<img src='case_tag_barcode.php?width=275&height=110&barcode=" . $oneYearFromNow . "'>";
$myItemTemplate->replace("expbarcode", $barcode);

$myItemTemplate->replace("expdate", $oneYearFromNow);


Any idea?
Member
Posts: 18,138
Joined: May 31 2010
Gold: 7.27
Mar 21 2017 12:29pm
also tried this:

Code
$barcode = "<img src='case_tag_barcode.php?width=275&height=110&barcode=" . date("m-d-y", strtotime + "1 years", strtotime($myOrd->hr_date)) . "'>";


but didn't work either.
Member
Posts: 1,741
Joined: Feb 8 2008
Gold: 2,186.00
Mar 25 2017 07:15pm
I'm not a PHP expert and don't really get what you're trying to do (your code seems to be pretty overcomplicated and there are references to the variables and that barcode generator file (?) that i don't know anything about). Do you just want to get the expiration date of the item (date when it was added + 365 days)? This little piece of code should do the job ->

Code
<?php

$start = "2017-03-21"; // Date when the item was added (just some rand)

$expires = strtotime($start. ' + 365 days');

echo "Expires: " . date('d-m-Y', $expires) ; // Just to show the expiration date

?>
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll