Jump to content


Photo

date questions *solved*


  • Please log in to reply
6 replies to this topic

#1 digitalgod

digitalgod
  • Members
  • PipPipPip
  • Advanced Member
  • 374 posts

Posted 09 August 2006 - 06:42 PM

hey guys,

trying to make a drop down that displays the days of the week starting by today but if it's past 9:15pm it shows the next day. I was wondering if I do something like
date('h:i:s a')
  would a user be able to "cheat" by changing the time on his taskbar?

Also how can I set the time to Eastern time all the time no matter where the user is from?

#2 Caesar

Caesar
  • Members
  • PipPipPip
  • Advanced Member
  • 1,025 posts

Posted 09 August 2006 - 06:46 PM

hey guys,

trying to make a drop down that displays the days of the week starting by today but if it's past 9:15pm it shows the next day. I was wondering if I do something like

date('h:i:s a')
  would a user be able to "cheat" by changing the time on his taskbar?

Also how can I set the time to Eastern time all the time no matter where the user is from?


PHP is a server-side language. The date() and time() functions use the server's current date.
PHP Ninja

#3 bltesar

bltesar
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts

Posted 09 August 2006 - 06:51 PM

because the date/time functions are executed on the server side, they will be independent of the client's machine settings.  To always have eastern time, you need to find out the time zone of your server and adjust accordingly
e.g.  date('h:i:s a', time()+3600); to add an hour to your server time.  

#4 digitalgod

digitalgod
  • Members
  • PipPipPip
  • Advanced Member
  • 374 posts

Posted 09 August 2006 - 08:17 PM

k thanks guys

just another question though

I have this
$days = array();
for ($i=1;$i<=7;$i++) {
	array_push($days,date("l", mktime(0,0,0,0,+$i,0)));
}
echo "<select name='days' ><option value=''>Select one</option>";
for($i=0;$i<=count($days);$i++) { 
	echo  '<option value='.$days[$i].'>'.$days[$i].'</option>';
}
echo "</select>";

that's supposed to display all the days from today till next tuesday but for some reason it adds a blank choice after tuesday, any reason why?

I know how to make it work, all I need to do is to replace the <= by <count($days).... never mind my brain isn't all there today by using <= it will loop 8 times instead of 7

#5 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 09 August 2006 - 08:19 PM

have you tried checking what's actually in the $days array?

#6 digitalgod

digitalgod
  • Members
  • PipPipPip
  • Advanced Member
  • 374 posts

Posted 09 August 2006 - 08:20 PM

yeah I did, it works perfectly akitchin, I'm just tired that's all :P

#7 bltesar

bltesar
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts

Posted 09 August 2006 - 08:33 PM

instead of <=count($days), you should have <count($days)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users