Jump to content

date questions *solved*


digitalgod

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?
Link to comment
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.
Link to comment
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.  
Link to comment
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
Link to comment
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.