Jump to content

Archived

This topic is now archived and is closed to further replies.

rocket

timestamps and strtotime...such a beginner

Recommended Posts

Hi, I am racking my brain to think of a solution for this. I have a website where the customer can have 1 of 3, or 2 of 3 outcomes.
The customer orders holiday cards for me to send to recipients.
The customer enters the date the recipients should receive the mail piece.
If they need a rush, recipients will receive the mail piece within 5 days.
If they don't need a rush, recipients will receive the mail piece after 5 days.
If they order by November 15, they get a 10% discount.

So I have the date that the customer enters in as, $month (m), $day (d), $year (Y). $recipship and $discount are the final variables to be carried on as session variables.

<?php
$day = $_POST['day'];
$_SESSION['day'] = $day;

$month = $_POST['month'];
$_SESSION['month'] = $month;

$year = $_POST['year'];
$_SESSION['year'] = $year;

$promotime = 1163556000;//this is November 15th 2006 timestamp. If ordered on or before this date, the cust gets 10% off.

$now = time();//now

$duedate = strtotime($month . $day . $year 00:00:00);//the customer entered in when the recipients should receive the cards and I'm trying to convert to timestamp

$rush = time() < (5 * 24 * 60 * 60);//this is supposed to equate (in timestamp form) that a rush will apply if the date entered is within 5 days from now.

$standard = time() >= (6 * 24 * 60 * 60);//this is supposed to equate (in timestamp form) that standard shipping will apply if the date entered is 6 days or more from now.

//here are my conditions to be met:

if ($duedate > $standard){
$recipship = 'Standard delivery, within 10 business days, $.09 per card additional plus postage.';
}

elseif ($duedate <= $rush){
$recipship = '5 days, $15.00 rush fee, $.09 per card plus postage.';

}


elseif ($now <= $promotime){
$discount = .90;

}


?>


Do I just have is all wrong??? Do I need to find a difference somewhere? I really don't know if I have the booleans right and I don't know if I have the variables defined correctly for the outcome that I want.

Finally, my problem is that none of the variables, $recipship or $discount are being carried through as session variables to the next page. So something is not right-

Any help, any explaination, anything will help me. very newbie, so go easy.

Thanks

Share this post


Link to post
Share on other sites
$recipship and $discount are not put into the session variable so won't be passed ie:

[code]
$_SESSION['recipship'] = $recipship;
$_SESSION['discount'] = $discount;
[/code]

I believe strtotime is the wrong function.  Here is the first example from the PHP Manual at php.net

[code]
<?php
echo strtotime("now"), "\n";
echo strtotime("10 September 2000"), "\n";
echo strtotime("+1 day"), "\n";
echo strtotime("+1 week"), "\n";
echo strtotime("+1 week 2 days 4 hours 2 seconds"), "\n";
echo strtotime("next Thursday"), "\n";
echo strtotime("last Monday"), "\n";
?>
[/code]

I'm thinking you're needing the mktime function in the manual at http://php.net/mktime

HTH

Dest

Share this post


Link to post
Share on other sites
The strtotime() function can be used. I use it all the time.

Try changing:
[code]<?php
$duedate = strtotime($month . $day . $year 00:00:00);
?>[/code]
to
[code]<?php
$duedate = strtotime("$year - $month - $day");
?>[/code]

Ken

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.