How to show local time and date
Moderator: General Moderators
How to show local time and date
Well I am not interested in getting time and date from users computer for my web site because sometime it does not give the right information. So do you have any other idea how I can get local time and date (approximately accurate) for my web site. Necessary code will be very helpfull. Thank you.
- Skittlewidth
- Forum Contributor
- Posts: 389
- Joined: Wed Nov 06, 2002 9:18 am
- Location: Kent, UK
- Skittlewidth
- Forum Contributor
- Posts: 389
- Joined: Wed Nov 06, 2002 9:18 am
- Location: Kent, UK
Use the date() function.
http://uk2.php.net/manual/en/function.date.php
will show you how to use it, but basically if you wanted to echo the time and date on to your webpage you would have:
This would output:
or just
for the time.
The URL above will show you a list of all the formatting options including how to adjust the timezone if your server is in a different country. Hope this helps.
http://uk2.php.net/manual/en/function.date.php
will show you how to use it, but basically if you wanted to echo the time and date on to your webpage you would have:
Code: Select all
<?php echo date("D, d M Y g:i A") ?>Code: Select all
Tue, 27 Jul 2004 2:42 PMCode: Select all
<?php echo date("g:i A") ?>The URL above will show you a list of all the formatting options including how to adjust the timezone if your server is in a different country. Hope this helps.
- Skittlewidth
- Forum Contributor
- Posts: 389
- Joined: Wed Nov 06, 2002 9:18 am
- Location: Kent, UK
Sorry, I saw that you couldn't use PHP from your other post after I'd replied. I just took for granted that you'd be asking from a PHP perspective!
I'm afraid you've reached the limit of my scripting knowledge if its not php related, so I'll let someone else answer this one!
If the date and time is just for decorative purposes, why not have a look at http://www.dynamicdrive.com/dynamicindex6/index.html for a script that displays date and time, its mostly javascript but they might have cgi stuff
I'm afraid you've reached the limit of my scripting knowledge if its not php related, so I'll let someone else answer this one!
If the date and time is just for decorative purposes, why not have a look at http://www.dynamicdrive.com/dynamicindex6/index.html for a script that displays date and time, its mostly javascript but they might have cgi stuff
just out of perdoc.com FAQs:
Code: Select all
use POSIX qw(strftime);
$now_string = strftime "%a %b %e %H:%M:%S %Y", localtime;