Zergman Posted September 29, 2010 Share Posted September 29, 2010 So I’ve noticed that when I use $time = date(“H:i:s”); The time should echo 21:57:49 In a 24hr format and it works except for when it turns 12pm till 1pm. Im checking my database and see 11:57:49 then 00:00:47 until 13:01:44 comes. So it’s showing 12pm as 12am in 24hr clock for some reason. I’ve googled this a lot and can’t find a reason. Any idea?! Quote Link to comment https://forums.phpfreaks.com/topic/214685-php-date-time-problem/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 29, 2010 Share Posted September 29, 2010 The code you did post is using smart/curly quotes and is probably causing the date format string some difficulty. Also, what is your code between that point and the query that is inserting the data into your table and how are you retrieving and displaying the results? Any of those things could be causing the problem. Quote Link to comment https://forums.phpfreaks.com/topic/214685-php-date-time-problem/#findComment-1117007 Share on other sites More sharing options...
Zergman Posted September 29, 2010 Author Share Posted September 29, 2010 I'm using a very simple mysql insert statement posting the value directly into the database. I also have the mysql column set to TIME type if that matters. For the longest time, I had the H:i:s in single quotes but someone mentioned that might be the problem and suggested double quotes. Not sure honestly Quote Link to comment https://forums.phpfreaks.com/topic/214685-php-date-time-problem/#findComment-1117012 Share on other sites More sharing options...
PFMaBiSmAd Posted September 29, 2010 Share Posted September 29, 2010 Well the code you did post produces a fatal php parse error because those are NOT double-quotes and since you did not post your code or answer how you are retrieving and displaying the results, no one here can directly help you with what your code is doing that is causing the problem. Quote Link to comment https://forums.phpfreaks.com/topic/214685-php-date-time-problem/#findComment-1117018 Share on other sites More sharing options...
Zergman Posted September 29, 2010 Author Share Posted September 29, 2010 Here's the code i'm currently working on. $username = $_SESSION['logged_user']; $time = date ("H:i:s"); $e_city = $_GET['e_city']; mysql_query(" INSERT INTO surveys (employee_city, ttime, Agent_id) VALUES ('$e_city', '$time', '$username') "); On different page To display the results SELECT employee_city, ttime, Agent_id FROM surveys Employee City: <?php echo $row['employee_city']; ?> Logged Time: <?php echo $row['time']; ?> Agent: <?php echo $row['Agent_id']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/214685-php-date-time-problem/#findComment-1117022 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.