Jump to content

Recommended Posts

Posted

I have a news table set up in MySQL.

 

My PHP code reads the date&time from the database using the following code:

$date=$rows["NewsDate"];

And prints it to html using:

echo "<td id=newsdate>$date</td></tr>";

(it's part of a table)

 

That all works fine.

 

In order to get data into the database, I simply use PHPmyAdmin to do so.

I use the NOW() function to get the current time and date automatically.

 

However, because I am in the UK, the time is out by 8 hours.

 

I have tried putting the following line into the .htaccess file in the same directory as the html file that is reading the database:

SetEnv TZ Europe/London

...but that didn't do anything.

 

Help!

Thanks :)

Posted
I have tried putting the following line into the .htaccess file in the same directory as the html file that is reading the database:

SetEnv TZ Europe/London

...but that didn't do anything.

 

Well it did actually do something but it didn't help your MySQL dates. What you did was change the date and time on your site when using php date(). As far as changing it for MySQL I can't help you but I'm sure somebody else can. :)

Posted

Actually you are right.

I did a test with:

<?php
echo date('d-m-Y H:i:s');
?>

...and the time was correct.

 

Instead of writing my news straight into PHPmyAdmin, if I created a php page/form to write the news to the database, would I need to alter the code to add on 8 hours or will the .htaccess modification do that for me?

 

Thanks :)

 

~~~~~UPDATE~~~~~~

 

Okay so I made that php page.

I get the date using:

$date=date('Y-m-d H:i:s');

That works.

 

But now I have two other problems:

  1. The time is 7 minutes out.
  2. Sometimes I need to change the content of the post. And the only way I can do that with the current setup is through PMA. Once I've changed the content, I like to update the time, but if I choose NOW(), it reverts back to being 8 hours out.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...