Jump to content

Archived

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

digitalgod

date questions *solved*

Recommended Posts

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 [code=php:0] date('h:i:s a') [/code]  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?

Share this post


Link to post
Share on other sites
[quote author=digitalgod link=topic=103596.msg412618#msg412618 date=1155148937]
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 [code=php:0] date('h:i:s a') [/code]  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?
[/quote]

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

Share this post


Link to post
Share on other sites
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.  

Share this post


Link to post
Share on other sites
k thanks guys

just another question though

I have this
[code=php:0]
$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>";
[/code]

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

Share this post


Link to post
Share on other sites
have you tried checking what's actually in the $days array?

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.