PHPNewbie12 Posted June 1, 2007 Share Posted June 1, 2007 Hello... I have the following. But I want to change this. - I need the script to check the $c_date field and if it's before June 1, 2007 then shipping will be the 7.95 + quantity, if not then it's going to be 8.95 + quantity. I'm having a hard time with validating the date and creating the if/then. How do I go about this? Thanks! <TD colspan="4"><div align="right"><B>Shipping & Handling</B></div></TD> <TD><? $shipping_handling = 7.95 + $total_quantity; ?><?=$price_type_name?><?=format_price($shipping_handling)?></TD> </TR> <TR> Quote Link to comment https://forums.phpfreaks.com/topic/53866-validating-dates/ Share on other sites More sharing options...
per1os Posted June 1, 2007 Share Posted June 1, 2007 <?php $date = strtotime('06/01/2007'); // june 1st 2007 if (time() < $date) { $shipping = 7.95; }else { $shipping = 8.95; } $shipping_handling = $shipping + $total_quantity; ?> Quote Link to comment https://forums.phpfreaks.com/topic/53866-validating-dates/#findComment-266287 Share on other sites More sharing options...
Barand Posted June 1, 2007 Share Posted June 1, 2007 $shipcost = ($row['c_date'] < '2007-06-01') ? 7.95 : 8.95; Quote Link to comment https://forums.phpfreaks.com/topic/53866-validating-dates/#findComment-266288 Share on other sites More sharing options...
PHPNewbie12 Posted June 1, 2007 Author Share Posted June 1, 2007 Hey again, Okay. Many thanks. I tried both of those and tested it out. ALL the orders are getting the 8.95 and it's making even records before June 1, 2007 get the 8.95 amount. I think I'm messing up on the fields I'm using. <? $c_date = strtotime('06/01/2007'); if (time() < $c_date) { $shipping = 7.95; }else { $shipping = 8.95; } $shipping_handling = $shipping + $total_quantity; ?> Question - earlier in the code it pulls the date for the top of the report where this script is $c_date = strtotime($order->create_date); Should I be validating it against create_date instead of $c_date? (do I hear laughing .... ? ha I think I'm getting the fields / rows mixed up) Quote Link to comment https://forums.phpfreaks.com/topic/53866-validating-dates/#findComment-266315 Share on other sites More sharing options...
per1os Posted June 1, 2007 Share Posted June 1, 2007 Just to clarify, the time() should be replaced by what comes out of the database. because today is June 1st it will always go for the 8.95. Quote Link to comment https://forums.phpfreaks.com/topic/53866-validating-dates/#findComment-266321 Share on other sites More sharing options...
PHPNewbie12 Posted June 1, 2007 Author Share Posted June 1, 2007 Many thanks. I said screw it to using the date range. I just used the report ID instead ... and it seems to work. The last record of yesterday was 1078 so now .. all the records less then 1078 have the propert Amounts. *shrugs* <? if ($order->id < 1078) { $shipping_handling = 7.95 + $total_quantity; }else { $shipping_handling = 8.95 + $total_quantity; } Thanks again.... Quote Link to comment https://forums.phpfreaks.com/topic/53866-validating-dates/#findComment-266325 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.