Practical Web Programming

Friday, February 29, 2008

PHP: How to Get the Current Server Date and Time

Adding date and time to your website gives it an impression of being fresh and updated regularly. In PHP, getting the current server date and time is a no brainer using the getdate() function.

To add date and time, see the PHP script below.

<html>
<head>
<title>DATE and TIME</title>
</head>

<body>
<?php
$date_array = getdate();
print "Server Date : $date_array[month] $date_array[mday], $date_array[year].<BR>";
print "Server Time : $date_array[hours]:$date_array[minutes]:$date_array[seconds]<BR>";
?>
</body>
</html>

0 comments:

Recent Post