Jump to content

Archived

This topic is now archived and is closed to further replies.

bojak71730

time and date and php

Recommended Posts

[code]<?php
print date("g:i:s A ");

print date("l, F jS, Y ");
?>[/code]

my problem is i cant make it tell me my system time on my computer and thats what i wana figure out instead its telling me my server time which is an hour a head of me how do i fix this?

Share this post


Link to post
Share on other sites
php is a server side language. it is parsed on the server. you cannot get your website to display your computer's personal time using php.

Share this post


Link to post
Share on other sites
Wellllll, he could by having his script adjust the server time by the offset of his computer OR using GMT he could remove all concern of the server time.

Share this post


Link to post
Share on other sites
[!--quoteo(post=369432:date=Apr 27 2006, 07:54 PM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ Apr 27 2006, 07:54 PM) [snapback]369432[/snapback][/div][div class=\'quotemain\'][!--quotec--]
php is a server side language. it is parsed on the server. you cannot get your website to display your computer's personal time using php.
[/quote]
well it wont show my time it would show anyone whose viewing it so like if u were viewing it then it would show your computer time and i think there is a way im just not sure how to it

Share this post


Link to post
Share on other sites
[!--quoteo(post=369436:date=Apr 27 2006, 09:01 PM:name=litebearer)--][div class=\'quotetop\']QUOTE(litebearer @ Apr 27 2006, 09:01 PM) [snapback]369436[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Wellllll, he could by having his script adjust the server time by the offset of his computer OR using GMT he could remove all concern of the server time.
[/quote]
yeh that's fine and dandy if all he's concerned about is it showing ONLY his time, but I somehow have this sneaking suspicion that that is not what he wants.

[!--quoteo(post=369437:date=Apr 27 2006, 09:02 PM:name=bojak_cates)--][div class=\'quotetop\']QUOTE(bojak_cates @ Apr 27 2006, 09:02 PM) [snapback]369437[/snapback][/div][div class=\'quotemain\'][!--quotec--]
well it wont show my time it would show anyone whose viewing it so like if u were viewing it then it would show your computer time and i think there is a way im just not sure how to it
[/quote]

yes i understand what you want it to do. but you can't do that in php. all php script is parsed before it ever reaches the client's computer. therefore, it is impossible for you to do this in php. now, you MAY be able to do this with some javascript. I'm not sure. I only know a few odds and ends in javascript.

edit:

as a matter of fact, yes you can do it with javascript. i did a google search and picked a random site and here you go (i'm sure you can take most of this code out as it makes it look all pretty and stuff):

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
<!-- Paste this code into the BODY of your HTML document -->

<BODY>

<div align="center">
<font face="Arial, Helvetica, Sans Serif" size="3" color="#0000FF"><b>
<span id="clock">

<script LANGUAGE="JavaScript">
// Script featured on Able2Know.com
// Find free scripts & get free help: [a href=\"http://search.able2know.com/web_development/scripts/\" target=\"_blank\"]http://search.able2know.com/web_development/scripts/[/a]
<!-- Original: Chris (javascript@crashedstar.com) -->
<!-- Web Site: [a href=\"http://www.crashedstar.com/\" target=\"_blank\"]http://www.crashedstar.com/[/a] -->

<!-- Begin
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
function getthedate(){
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var hours=mydate.getHours()
var minutes=mydate.getMinutes()
var seconds=mydate.getSeconds()
var dn="AM"
if (hours>=12)
dn="PM"
if (hours>12){
hours=hours-12
}
{
d = new Date();
Time24H = new Date();
Time24H.setTime(d.getTime() + (d.getTimezoneOffset()*60000) + 3600000);
InternetTime = Math.round((Time24H.getHours()*60+Time24H.getMinutes()) / 1.44);
if (InternetTime < 10) InternetTime = '00'+InternetTime;
else if (InternetTime < 100) InternetTime = '0'+InternetTime;
}
if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
//change font size here
var cdate=dayarray[day]+", "+montharray[month]+" "+daym+" "+year+" | "+hours+":"+minutes+":"+seconds+" "+dn+" | @"+InternetTime+""
if (document.all)
document.all.clock.innerHTML=cdate
else if (document.getElementById)
document.getElementById("clock").innerHTML=cdate
else
document.write(cdate)
}
if (!document.all&&!document.getElementById)
getthedate()
function goforit(){
if (document.all||document.getElementById)
setInterval("getthedate()",1000)
}
window.onload=goforit
// End -->
</script>

</span>
</b>
</font>
</div>
[/quote]

Share this post


Link to post
Share on other sites
i looked at some javascript stuff and ur right i can make it in javascript thanks alot php cant do it cause it cant get the time from ur machine i had to think about that one lol thanks so much

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.