Hi, How can i return the server date? using

<?php $my_t=getdate(date("U")); 
print("$my_t[weekday], $my_t[month] $my_t[mday], $my_t[year]"); ?>

gives me errors :(

Thanks in advance, I know it probably has a very easy solution, but I just dont know what as I'm so totally new to php..

Recommended Answers

All 5 Replies

Try this

<?
$day=getdate();
echo($day['wday']."/".$day['mon'])."/".$day['year']);
?>

Hi,

I am sharing a tip with you.

Sometimes our server shows a different time than the time shown on our clock, the most probable reason is that our hosting server is in a different time-zone.

We can easily set our server time to our time zone changing a setting in PHP called date.timezone.
In order to set the new time in every file, we need not update the new time in all the files, all that we would need to do is replace a single line in htaccess file.

To set a time zone for your entire account or directory, create a .htaccess file in the upper directory with the line:

Hope you find this tips useful and of assistance.

Thanks,
Suryakant

You may write like this also.
<?php print date("Y-m-d H:i:s"); ?>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.