How to use date in PHP

In this article I am going to explain about use of date function in PHP.
  • 2059

PHP Date() function

The php date function allow programmer or developers to manipulate date in easy way.

Syntax of PHP date function

date(format,timestamp)


Parameters in date function

  • format

    The format of the outputted date string.
     

  • timestamp

    It is an optional parameter in date function and its specifies a timestamp.

Format of the date function

There are following format of date function
 

Format character Description
d Day of the month, 2 digits with leading zero.(01 to 31)
m Numeric representation of a month,with leading zero (01 to 12)
Y A full numeric representation of a year,4 digit (four digit)

Example of date function

<html>

<head>

<body>

<?php

echo date("Y/m/d") . "<br />";

echo date("Y.m.d") . "<br />";

echo date("Y-m-d");

?>

</body>
</head>
</html>


Output:

date fun.jpg

You may also want to read these related articles :here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2020 DotNetHeaven. All rights reserved.