Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Open the index.php file for this application and review the code. Note that it displays a starting invoice date thats one month before the

1. Open the index.php file for this application and review the code. Note that it displays a starting invoice date thats one month before the current date and a starting due date thats two months after the current date. However, this code doesnt process the dates that are entered into the text boxes. 2. Open the date_tester.php file for this application and review the code. Note that this code uses an if statement to display an error message or a table of date and time data. 3. In the index.php file, add the code that uses the two dates that are entered into the text box controls to display a table of data that calculates dates and times and formats them like this: Invoice date: Due date: Current date: Current time: Due date message: July 11, 2014 October 11, 2014 August 11, 2014 4:40:16 pm This invoice is due in 0 years, 1 months, and 29 days. If the current date is after the due date, the due date message should be in this format: Due date message: This invoice is 0 years, 2 months, and 25 days overdue. 4. Make sure the user enters both dates. 5. Allow the user to enter a date in any format that can be parsed by the constructor of the DateTime class. This includes all of the most common date formats. 6. Make sure the user enters dates in a valid date format. To do that, you can use a try/catch statement to catch an exception thats thrown if the constructor of the DateTime class cant parse the date. For a review of the try/catch statement, you can refer to chapter 4. 7. Make sure the user enters a due date thats later than the invoice date. 8. Test the application to make sure it works correctly.

switch ($action) { case 'start_app':

// set default invoice date 1 month prior to current date $interval = new DateInterval('P1M'); $default_date = new DateTime(); $default_date->sub($interval); $invoice_date_s = $default_date->format('n/j/Y');

// set default due date 2 months after current date $interval = new DateInterval('P2M'); $default_date = new DateTime(); $default_date->add($interval); $due_date_s = $default_date->format('n/j/Y');

$message = 'Enter two dates and click on the Submit button.'; break; case 'process_data': $invoice_date_s = $_POST['invoice_date']; $due_date_s = $_POST['due_date'];

// make sure the user enters both dates

// convert date strings to DateTime objects // and use a try/catch to make sure the dates are valid

// make sure the due date is after the invoice date

// format both dates

// get the current date and time and format it

// get the amount of time between the current date and the due date // and format the due date message

break; } include 'date_tester.php'; ?>

Date Tester

Date Tester




Message:

Invoice date:
Due date:
Current date:
Current time:
Due date message:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PC Magazine Guide To Client Server Databases

Authors: Joe Salemi

1st Edition

156276070X, 978-1562760700

More Books

Students also viewed these Databases questions