rocket Posted October 29, 2006 Share Posted October 29, 2006 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 Link to comment https://forums.phpfreaks.com/topic/25517-timestamps-and-strtotimesuch-a-beginner/ Share on other sites More sharing options...
Destruction Posted October 29, 2006 Share Posted October 29, 2006 $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]<?phpecho 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/mktimeHTHDest Link to comment https://forums.phpfreaks.com/topic/25517-timestamps-and-strtotimesuch-a-beginner/#findComment-116448 Share on other sites More sharing options...
kenrbnsn Posted October 29, 2006 Share Posted October 29, 2006 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 Link to comment https://forums.phpfreaks.com/topic/25517-timestamps-and-strtotimesuch-a-beginner/#findComment-116460 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.