Jump to content

PHP Date / Time problem


Zergman

Recommended Posts

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?!

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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']; ?>

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.