DeanWhitehouse Posted April 21, 2008 Share Posted April 21, 2008 i have a code to write the time of a post to a database, this code is meant to detect time zones, but it doesn't detect daylight saving. How can i add this $datetime=date("jS of M Y h:ia e"); e is the code for the timezone detection Quote Link to comment https://forums.phpfreaks.com/topic/102205-timezone-detection/ Share on other sites More sharing options...
AndyB Posted April 21, 2008 Share Posted April 21, 2008 I (capital i) Whether or not the date is in daylight saving time 1 if Daylight Saving Time, 0 otherwise. That's from the manual. Perhaps DST is not in play at the location where your server resides. Quote Link to comment https://forums.phpfreaks.com/topic/102205-timezone-detection/#findComment-523225 Share on other sites More sharing options...
DarkWater Posted April 21, 2008 Share Posted April 21, 2008 You can't get the user's local time with PHP. Just Javascript. >_> Be creative. Quote Link to comment https://forums.phpfreaks.com/topic/102205-timezone-detection/#findComment-523237 Share on other sites More sharing options...
DeanWhitehouse Posted April 21, 2008 Author Share Posted April 21, 2008 but if i use javascript, i can't insert that into a database Quote Link to comment https://forums.phpfreaks.com/topic/102205-timezone-detection/#findComment-523243 Share on other sites More sharing options...
DarkWater Posted April 21, 2008 Share Posted April 21, 2008 Have them mark their local time zone and DST settings on an options page, or put their local time in a hidden input that you make with Javascript. =P There's a way to do anything that you need done. * *Some conditions apply. See official rules for details. Quote Link to comment https://forums.phpfreaks.com/topic/102205-timezone-detection/#findComment-523245 Share on other sites More sharing options...
dptr1988 Posted April 21, 2008 Share Posted April 21, 2008 JavaScript can collect the information, put it into a form and post the form, then PHP will receive the form and put it in the database. Or you can use AJAX to send the info to the PHP script. Quote Link to comment https://forums.phpfreaks.com/topic/102205-timezone-detection/#findComment-523249 Share on other sites More sharing options...
DeanWhitehouse Posted April 21, 2008 Author Share Posted April 21, 2008 well this is the page where the date is inserted. <?php require_once 'db_connect.php'; require_once 'config_table.inc.php'; // get data that sent from form $topic=$_POST['topic']; $detail=$_POST['detail']; $name=$_POST['name']; $email=$_POST['email']; $datetime=date("jS of M Y h:ia e"); //create date time $sql="INSERT INTO $forum_quest(topic, detail, name, email, datetime)VALUES('$topic', '$detail', '$name', '$email', '$datetime')"; $result=mysql_query($sql); if($result){ echo "Successful<BR>"; echo "<a href=main_forum.php>View your topic</a>"; } else { echo "ERROR"; } mysql_close(); ?> could i change it to this <?php require_once 'db_connect.php'; require_once 'config_table.inc.php'; // get data that sent from form $topic=$_POST['topic']; $detail=$_POST['detail']; $name=$_POST['name']; $email=$_POST['email']; $datetime=?><html><script type="text/javascript"> var d = new Date(); document.write(d.getHours()); document.write("."); document.write(d.getMinutes()); document.write("."); document.write(d.getSeconds()); </script> </html>//create date time <?php $sql="INSERT INTO $forum_quest(topic, detail, name, email, datetime)VALUES('$topic', '$detail', '$name', '$email', '$datetime')"; $result=mysql_query($sql); if($result){ echo "Successful<BR>"; echo "<a href=main_forum.php>View your topic</a>"; } else { echo "ERROR"; } mysql_close(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/102205-timezone-detection/#findComment-523251 Share on other sites More sharing options...
DarkWater Posted April 21, 2008 Share Posted April 21, 2008 No, dude, put it on the page with the form and have it sent over POST. Quote Link to comment https://forums.phpfreaks.com/topic/102205-timezone-detection/#findComment-523255 Share on other sites More sharing options...
DeanWhitehouse Posted April 21, 2008 Author Share Posted April 21, 2008 how would i do that? <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form id="form1" name="form1" method="post" action="add_topic.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3" bgcolor="#E6E6E6"><strong>Create New Topic</strong> </td> </tr> <tr> <td width="14%"><strong>Topic</strong></td> <td width="2%">:</td> <td width="84%"><input name="topic" type="text" id="topic" size="50" /></td> </tr> <tr> <td valign="top"><strong>Detail</strong></td> <td valign="top">:</td> <td><textarea name="detail" cols="50" rows="3" id="detail"></textarea></td> </tr> <tr> <td><strong>Name</strong></td> <td>:</td> <td><input name="name" type="text" id="name" size="50" /></td> </tr> <tr> <td><strong>Email</strong></td> <td>:</td> <td><input name="email" type="text" id="email" size="50" /></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Submit" /> <input type="reset" name="Submit2" value="Reset" /></td> </tr> </table> </td> </form> </tr> </table> the form that is sent. i don't want to show them the time when it is sent Quote Link to comment https://forums.phpfreaks.com/topic/102205-timezone-detection/#findComment-523263 Share on other sites More sharing options...
dptr1988 Posted April 21, 2008 Share Posted April 21, 2008 I use a hidden input field. google for 'html form input hidden' Quote Link to comment https://forums.phpfreaks.com/topic/102205-timezone-detection/#findComment-523268 Share on other sites More sharing options...
AndyB Posted April 21, 2008 Share Posted April 21, 2008 i don't want to show them the time when it is sent Why? They know what time it is, don't they? Quote Link to comment https://forums.phpfreaks.com/topic/102205-timezone-detection/#findComment-523309 Share on other sites More sharing options...
DeanWhitehouse Posted April 21, 2008 Author Share Posted April 21, 2008 its so they no when the forum post was posted, but in there time zone Quote Link to comment https://forums.phpfreaks.com/topic/102205-timezone-detection/#findComment-523316 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.