Jump to content

Recommended Posts

[!--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
Link to comment
https://forums.phpfreaks.com/topic/8596-time-and-date-and-php/#findComment-31528
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]
Link to comment
https://forums.phpfreaks.com/topic/8596-time-and-date-and-php/#findComment-31535
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.