Show Server Date on an HTML Page

Hello,

Please can anyone show me a simple way to show the current server date on an HTML page?

Javascript is OK.  Please, just as easy as possible.

Thanks!!

ubee...
a466-ub52Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BogoJokerCommented:
Hi a466-ub52,

Funny you said javascript, that is client-side and it will show the time on your computer, not the server computer.
Here is an example:
<script type="text/javascript">
document.write(Date())
</script>

If you want the server's time you should use a time() function in PHP or something in ASP, depending on which you are using.  That is a server-side script that will execute on the server.
Here is a php example:
<?php print time(); ?>

You can improve both of those examples by creating a Date object in either, to format however you want it.
Joe P
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
a466-ub52Author Commented:
Hi there,

Thanks for you reply!

How would I include that php inside an HTML page?

Thanks!!

ubee...
0
BogoJokerCommented:
Cut and paste that exact like that I wrote:
<?php print time(); ?>

I can format it however you want, did you want dd/mm/yyyy or hour:min:second, tell me how you would like it.
Also you must have PHP enabled on your server for this to work.  Hopefully you have php.

Joe P
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

a466-ub52Author Commented:
Hello Joe,

That's great.  Thanks so much!!  Please like this:

Wednesday Apr 19 2006

ubee...

0
BogoJokerCommented:
Sure:
<?php print date("l M j Y"); ?>

That prints what you want, the only thing you can change is if you want leading zeros on the day like:
Wednesday Apr 05 2006 instead of Wednesday Apr 5 2006 then use:
<?php print date("l M d Y"); ?>

Joe P
0
a466-ub52Author Commented:
Hmmm... coming up empty.  Is there any special leading code to help the HTML recognize the php?

Thanks!!

ubee...
0
BogoJokerCommented:
Once again, do you have php installed on the webserver?

Joe P
0
a466-ub52Author Commented:
Hi Joe P,

Need to edit the htaccess file, apparently. So, just saved it as a .php file.  Your solution is perfect!  THat's save me so much S E A R C H I I I I N G!!  Thanks!! ~~

Are there any other nifty one line thigs like that that you are fond of.  Little things one can drop into a page that you like?

Thanks again for your help

ubee...

0
BogoJokerCommented:
Hehe, that was not that hard. =)
Whatever you want, little things like that, a visit counter, small stuff like that we can work up little scripts.
Joe P
0
a466-ub52Author Commented:
Anything you think is just cool & fun / useful for visitors?  How about server temperature? :)

Thanks!!

ubee...
0
BogoJokerCommented:
Hmm, that is a good idea.  Get the temperature.  You could get an RSS feed from weather.com or some place, use a regular expression to get the temperature.  Everytime the page is reloaded it would get that xml (RSS feed is xml) and find the temperature and print that.  To get the weather of the person visiting the site you would need their zip code.  If you have logged in users visiting your site that would make more sense.

Joe P
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.