Jump to content


Photo

time and date and php


  • Please log in to reply
5 replies to this topic

#1 bojak71730

bojak71730
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 28 April 2006 - 01:13 AM

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

print date("l, F jS, Y ");
?>

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?

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 28 April 2006 - 01:54 AM

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.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 litebearer

litebearer
  • Members
  • PipPipPip
  • Advanced Member
  • 2,357 posts
  • Locationwhite lake michigan

Posted 28 April 2006 - 02:01 AM

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.

all the brothers were valiant!

[br][br]The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture

#4 bojak71730

bojak71730
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 28 April 2006 - 02:02 AM

[!--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) View Post[/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

#5 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 28 April 2006 - 02:22 AM

[!--quoteo(post=369436:date=Apr 27 2006, 09:01 PM:name=litebearer)--][div class=\'quotetop\']QUOTE(litebearer @ Apr 27 2006, 09:01 PM) View Post[/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) View Post[/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]
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#6 bojak71730

bojak71730
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 29 April 2006 - 02:53 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users