pTutorial

New way to learn PHP Example

How To Print Current Date In PHP

Display current day

In this section, we will learn more about date function and print the current day with the help of the date function.

<?php

$day = date("l");
 
echo "Today is "."$day";


?>

Explanation

It is the easiest method to print current day. You can use the date function with "l" argument.

$day is a simple variable that holds the current day, you can print the current day with the help of echo construct.

Switch case example

<?php

$day = date("l");
	switch($day)
	{
		    case "Sunday":
            $var = $day;
			break;
		    case "Monday":
			$var = $day;
			break;
		    case "Tuesday":
			$var = $day;
			break;
		    case "Wednesday":
			$var = $day;
			break;
            case "Thursday":
			$var = $day;
			break;
		    case "Friday":
			$var = $day;
			break;
		    case "Saturday":
			$var = $day;
			break;
			default:
			print "Input is wrong";
	 }
	 echo("Today is "."$var");



?>

Explanation

In this example, we are using switch case with date function and print current day. If you want to make a schedule of the week, you can make by using this script.

You can use this script for making the weekly schedule like Sunday is the holiday etc.


QUOTES OF THE DAY

A single death is tragedy, a million death is a static.

LIKE ON FACEBOOK

+1 ON GOOGLE

SHARE ON TWITTER