SEC S20W6 || Date & Time Types And String Predefined Methods in PHP

Assalamualaikum my fellows I hope you will be fine by the grace of Allah. Today I am going to participate in the steemit engagement challenge season 20 week 6 by @kouba01 under the umbrella of steemit team. It is about Date & Time Types And String Predefined Methods in PHP. Let us start exploring this week's teaching course.

Green Tosca Modern Geometric Web Hosting Service Presentation.png

Made with Canva

Multiple Choice Quiz

1. What does the checkdate function do in PHP?

  • A. It formats a date into a specific string.
  • B. It checks if a date is valid based on the day, month, and year.
  • C. It returns the current timestamp.
  • D. It adds a period to a date field.

B. It checks if a date is valid based on the day, month, and year.

Explanation: The checkdate function verifies whether the provided day, month, and year form a valid date. For example, it will return false for February 30th, as this date does not exist.


2. What does the date function return if no timestamp is provided?

  • A. The system's current date and time as a formatted string.
  • B. The time elapsed since 1970 in seconds.
  • C. The timestamp for midnight of the current day.
  • D. A boolean value indicating whether the current date is valid.

A. The system's current date and time as a formatted string.

Explanation: If the date function is called without a timestamp, it uses the current date and time of the server by default. The format specified in the function’s parameters is applied to this current date and time.


3. Which of the following is true about the mktime function in PHP?

  • A. It returns the current system timestamp.
  • B. It generates a timestamp based on provided hour, minute, second, day, month, and year values.
  • C. It checks the validity of a date.
  • D. It converts a timestamp into a human-readable string.

B. It generates a timestamp based on provided hour, minute, second, day, month, and year values.

Explanation: The mktime function is used to create a Unix timestamp from specified date and time components. If any of these components are omitted, they default to the current values.


4. What is the purpose of the strtotime function in PHP?

  • A. It formats a date according to a specific format.
  • B. It converts an English date string into a Unix timestamp.
  • C. It compares two date strings.
  • D. It checks if a date is in the future.

B. It converts an English date string into a Unix timestamp.

Explanation: The strtotime function takes a string representation of a date and time and converts it into a Unix timestamp. This is particularly useful for parsing human-readable date formats.

String Functions

  • Question 1


    image.png

  • Question 2


    image.png

  • Question 3


    image.png

  • Question 4


    image.png

  • Question 5


    image.png

Here I have split the string for the ease of visual representation because my screen was not enough to capture the code and output without splitting it. But the main functionality is executed.

  • Question 6


    image.png

  • Question 7


    image.png


A- Creation of the Database

I am using local server via XAMP. For the creation of the database in my local storage I have start Apache and MySQL.


image.png

To open the database I have accessed it through http://localhost/phpmyadmin/. It opened the database linked with my XAMP server.

EquipementLeisure database creation manually.


image.png

  • Client Table
    image.png
  • Equipment Table
    image.png
  • Rental Table
    image.png

  • Insert four records of your choice into the Client table.
    image.png
    image.png

  • Insert the following rows into the Equipment table:
    image.png
    image.png

  • The Client table has customer information such as Ncin, name, and phone number.

  • The Equipment table has equipment data. It has a check constraint on the "Available" field to accept only 'O' or 'N' values.

  • The Rental table links clients and equipment along with the rental and return dates.


B- Creation of Web Documents

  • index.html Page
    image.png

I have divided all the space of the page according to the required layout and design. Zone 1 is for the header, zone 2 is for the links. Zone 3 is for the display of the content. Zone 4 is for the footer.

  • Creation of the form on the "Location.html" page.
    image.png

I have created this form in location.html and all the input fields are required. If the user does not fill the fields, then he will not be able to submit it.

  • Validation Script of PHP at location.php
    image.png
    image.png

  • Creation of the form on the "Return.html" page.
    image.png

  • Validation Script of PHP at Retour.php.php
    image.png
  • Creation of the page "Statistics.php"
    image.png
    image.png
    image.png

I have just shared all the html and PHP pages and the main file of CSS is excluded which was used to manage the design and layout of the page.

In this video I have explained everything. I have added items to the rent. Those were also added in the Statistics page. And if an item is not available then we cannot get that item for rent. If we enter wrong Ncin then the system restricts us by showing an error message of incorrect Ncin. Moreover you can check all the functionality in the video.

I am inviting @chant, @nancy and @otisbrown in this last week of Engagement Challenge.

Sort:  

Thank you, @akmalshakir, for publishing an article using our tag #dynamicdevs-s20w6. We have assessed your article and present the results of the evaluation below.


Criteria Remark
#steemexclusive
Free of Plagiarism
AI Article ✅ Original (Human text!)
Bot free

Comment/Recommendation


Task 1 (1/1)

Your responses and explanations for each multiple-choice question demonstrated a solid understanding of PHP date and time functions.

Task 2 (3/3)

  • Question 1 to 7: You effectively implemented string functions such as strlen(), strpos(), str_replace(), and strrev(). Each code was accurate, and the results were correctly displayed.

  • You provided screenshots and explanations for each, which showed a clear understanding of how string manipulation works in PHP.

Project (5.7/6)

Your database and web application creation were well-executed. Here’s an assessment of your project:

A. Database Creation:

  • You successfully created the "EquipementLeisure" database with the appropriate tables for clients, equipment, and rentals. The relationships between the tables were well-established, and the constraints for the fields were correctly implemented (e.g., the 'Available' field accepting only 'O' or 'N').
  • You provided screenshots showing the database creation process, which helped demonstrate your SQL proficiency.

B. Web Documents:

  • Index page: The design of the index page was clean and correctly divided into the required zones (header, navigation links, content display, and footer).

  • Location page and PHP script: The form on the Location.html page was well-designed with required input fields. Your PHP validation script for location.php worked effectively, ensuring that users could not rent unavailable equipment or enter incorrect Ncin values.

  • Return page: The Return.html form and the Retour.php validation script were implemented correctly. The logic for updating equipment availability after return was well-handled.

  • Statistics page: You correctly displayed the rental details, including rental date, return date, hourly price, and rental duration. The calculations were accurate, and the layout of the statistics page was functional.

  • CSS Styling: Although the CSS file was not included, the visual layout shown in your screenshots demonstrated a clear and well-organized design.

Improvements:

  • Including the CSS file and showing more interactive elements (e.g., dynamic validation or modal pop-ups) could further improve the project’s usability and design.

Final Score:

Total | 9.7/10

This is an excellent submission, showcasing a strong understanding of PHP, string manipulation, and database design. The project was well-implemented, with a few minor areas for improvement in presentation. Keep up the great work!

Thank you 🙏

New to Steemit?