Page 1 of 1

Format today's date in several ways

Posted: Tue Feb 21, 2017 5:33 pm
by codeflavour
Do you want to display today's date in your code? Easy enough, right!

Well what if you wanted to format today's date in a different way? Use the following code to do that!

Code: Select all

<!DOCTYPE html>
<html>
<body>

<?php
echo "Today is " . date("Y/m/d") . "<br>";
echo "Today is " . date("Y.m.d") . "<br>";
echo "Today is " . date("Y-m-d") . "<br>";
echo "Today is " . date("l");
?>

</body>
</html>
The output will look like this:

Today is 2017/02/21
Today is 2017.02.21
Today is 2017-02-21
Today is Tuesday

There are many variations you can do!

Re: Format today's date in several ways

Posted: Wed Feb 22, 2017 10:46 am
by AnimusVox
Thanks so much, this really helped! :D