PHP - Add Working/business Days To A Date
is there an easy way to add weekdays to a stored date ... so far i have
echo date ( 'Y-m-j' , strtotime ( '5 weekdays' ) ); this adds 5 weekdays to the current date , can i have it add 5 weekdays to say $TableDate 1; Thanks in advance... Similar TutorialsHi all, I am trying to figure out how to calculate 5 working days prior to a given date. I have done some googling but can only see examples of how to add 5 working days onto a date, such as this: Code: [Select] $holidayList = array(); $j = $i = 1; while($i <= 5) { $day = strftime("%A",strtotime("+$j day")); $tmp = strftime("%d-%m-%Y",strtotime("+$j day")); if($day != "Sunday" and $day != "Saturday" and !in_array($tmp, $holidayList)) { $i = $i + 1; $j = $j + 1; } else $j = $j + 1; } $j = $j -1; echo strftime("%A, %d-%m-%Y",strtotime("+$j day")); Does anyone know how to calculate 5 working days prior to a date? Many thanks, Greens85 Hi, I have a job listing website which displays the closing date of applications using: $expired_date (This displays a date such as 31st December 2019) I am trying to show a countdown/number of days left until the closing date. I have put this together, but I can't get it to show the number of days. <?php $expired_date = get_post_meta( $post->ID, '_job_expires', true ); $hide_expiration = get_post_meta( $post->ID, '_hide_expiration', true ); if(empty($hide_expiration )) { if(!empty($expired_date)) { ?> <span><?php echo date_i18n( get_option( 'date_format' ), strtotime( get_post_meta( $post->ID, '_job_expires', true ) ) ) ?></span> <?php $datetime1 = new DateTime($expired_date); $datetime2 = date('d'); $interval = $datetime1->diff($datetime2); echo $interval->d; ?> <?php } } ?> Can anyone help me with what I have wrong? Many thanks I want to see if a date is more than 10 days overdue. if ($row['duedate'] < "todays date plus 10 days"){ How do I do that? I put in quote sup there in "english" what I want... Hi there, i am using a form with 2 inputs which are equipped with a datepicker: Date 1 & Date 2, is it possible to calculate how many days are there from Date 1 to Date 2 (including the selected ones) ? On my form the dates are in this format: September 08, 2011 (i guess i can change that to numeric only, if that helps) Tamper data shows them getting posted like this: September+14%2C+2011 Any help / hints will be appreciated ! I have a SQL row that has a date field: ex: 2010-11-01. When a car is sold there either is a 30 day warranty, a 60 day warranty, or 0 day warranty. What I'm trying to do is display when the vehicles warranty expires, based on the date it was sold, or when did it expire based on the same sold date pulled from the database. Example using last months date: 2010-10-01 60 day: "Expires 11-30-10" 30 day: "Expired 11-01-10" I can not seem to use the date function properly... Any help would be greatly appreciated. Hi guys, I've hit a brick wall here and am in need of your help. I'm pretty new to PHP and have limited knowledge to say the least. I'll explain what it is I'm trying to do. Set start date as 01/01/2004 (dmY) $oFour Set how many days has it been since then? $today Set how many days it was from $ofour 30 days ago. $today -30 = $thirtyDaysAgo But the problem is I don't know how to make date('z'); work from 2004 and not 01/01/2010. So $today will be how many days it has been since the start of 2004 and $thirtyDaysAgo will be $today -30. I can set up $thirtyDaysAgo no problem but it's just finding out how to get the $today number... Hope anyone can offer a little light to my situation :/ Mav Hi fellas, this is really kicking my arse and i know its so simple! I retrieve a date from the database, done! I am manipulating it to display as i want, done! How the hell do i add 365 days to this date? $date= ($row['date']); $subscription = strtotime($date); echo "<p>Subscription renewal date: ". date('l jS F Y', $subscription) . "</p>"; I was wondering if there was a way to have the MAX function NOT return a Date that is more than 2 days into the future (from the current day)? If there is a Date that is more than 2 days into the future I would like to return the one closest to the current day. Here is the code I have: Code: [Select] <?php mysql_connect("local", "xxx", "xxx") or die(mysql_error()); mysql_select_db("pricelink") or die(mysql_error()); // Get a specific result from the "ft9_fuel_tax_price_lines" table $query ="SELECT ItemNumber,TableCode,Cost, MAX(`Date`) as `max_date`, MAX(`Time`) as 'max_time' FROM `ft9_fuel_tax_price_lines` GROUP BY `ItemNumber`,`TableCode`"; $result = mysql_query($query) or die(mysql_error()); echo "<table border='1'>"; echo "<tr> <th>ItemNumber</th> <th>TableCode</th> <th>Date</th> <th>Time</th> <th>Cost</th> </tr>"; // keeps getting the next row until there are no more to get while($row=mysql_fetch_array($result)) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['ItemNumber']; echo "</td><td>"; echo $row['TableCode']; echo "</td><td>"; echo $row['max_date']; echo "</td><td>"; echo $row['max_time']; echo "</td><td>"; echo $row['Cost']; echo "</td></tr>"; } echo "</table>"; ?> Any help would be appreciated. Thanks! Hi, I am trying to get the number of days between the current date and a date in the future specified by column 'end_date'. The code I have seems to be working but it displays the number of days as a negative number, how do I change this to be a positive number? I have tried simply changing $days = $now - $end_date; to $days = $end_date - $now; but that doesn't work as I thought it would! Thanks in advance.. Code: [Select] $now = time(); $end_date = strtotime($row['end_date']); $days = $now - $end_date; echo floor($days/(60*60*24)); I have date stored in database in any of the given forms 2020-06-01, 2020-05-01 or 2019-04-01 I want to compare the old date with current date 2020-06-14 And the result should be in days. Any help please? PS: I want to do it on php side. but if its possible to do on database side (I am using myslq) please share both ways🙂 Edited June 14, 2020 by 684425Hellow, i need help please, writing code and it doesn't work. please help...
Here it is
WHERE start_date BETWEEN 'start_date".strtotime('-3 day')."' AND 'start_date'";without this code everithing works fine Thank you I am looking at a website which will have a number of items on it advertised,such as:
businesses
jobs
property
etc
what I want to know is when designing the database would you have these in one table or a table for each?
Edited by brown2005, 14 October 2014 - 08:43 AM. Hello, everyone. I'm still kind of new at this, so please bear with me. I've customized a website (hosted by Yahoo Small Business) which is now fully functional aside from the "Contact Us" page. I have a PHP file named "send_email.php" uploaded to my root directory which has the following code: <?php $contact_name = $_POST['name']; $contact_email = $_POST['email']; $contact_subject = $_POST['subject']; $contact_message = $_POST['message']; if( $contact_name == true ) { $sender = $contact_email; $receiver = "my@email.com"; $client_ip = $_SERVER['REMOTE_ADDR']; $email_body = "Name: $contact_name \nEmail: $sender \n\nSubject: $contact_subject \n\nMessage: \n\n$contact_message \n\nIP: $client_ip \n\nFlash Contact Form provided by http://www.flashmo.com"; $extra = "From: $sender\r\n" . "Reply-To: $sender \r\n" . "X-Mailer: PHP/" . phpversion(); if( mail( $receiver, "Flash Contact Form - $contact_subject", $email_body, $extra ) ) { echo "success=yes"; } else { echo "success=no"; } } ?> I went ahead and changed "my@email.com" to my actual email address. The problem I'm having, though, is that the form fails every time...except if I enter my own email address in the "Email" field which should be filled in by the customer. I can't figure this out. It's probably something simple that I'm doing wrong, or perhaps it has something to do with Yahoo Web Hosting. I'm also thinking I have to fill something in the "Client IP" section of the code...but I'm not sure what should go there. I'd really appreciate your time and responses. Thanks so much. I have a web app that sends out notifications. I set it up to send through Google business, but they have an outbound limit. Does anyone know of a mail service that lets you send an unlimited amount of outbound and actually works good? Hi all, I need to get all businesses including details from http://www.nswbusinesschamber.com.au/Business-directory.aspx?name=&location= . What is the best way to approach this? Are there any scripts out there? Thanks... Hi, I have a small business and I'm looking to bring on a full stack PHP developer.
I'd like for the applicants to build a small full stack example application before I decided. Can anyone help me with cool -- samll -- example projects that might be appropriate for interviews? All the examples online are NOT full stack examples, and very basic -- like writing a file, etc. I need a small full stack application example that's not too big to scare off but not so small it won't matter.
Thanks! Hi,
Can anyone recommend some Business Intelligence tools that can be integrated into a PHP (wordpress/joomla) based website? I've had a good look around the net but they all seem to be written in Java/J2EE and appear to be software based - not sure if im after the possible or impossible here...
Thanks
I am trying to check if a credit card has expired. My criterion is whether or not the date submitted is prior to this month if the year matches 2011. Code: [Select] // Check for Expired Card. if (($expYear = date('Y')) && ($expMonth < date('M'))){ $errors['expDate'] = 'Expiration Date cannot be in the past.'; } Why is this not working? I chose March 2011 and it fails. In fact, it fails for any date?! Debbie I have a piece of .php that is supposed to create a type of calendar but it seems to be getting the date wrong and thinks that the date I've selected is 12/31/1969. Any ideas on how to get it to recognize the date I'm selecting in the form items? Thanks! Morgan [attachment deleted by admin] Hi, I'm making an RSS feed http://dev.subverb.net/mixes_rss.php and as you see the date('r', $row['date']) function is not converting it. I've echo'd $row['date'] into the description to show what format the date is in (just mysql datetime. Am I missing something? Thanks |