[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 152
  • Last Modified:

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...
0
a466-ub52
Asked:
a466-ub52
  • 6
  • 5
1 Solution
 
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
 
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now