charlie
charlie

Reputation: 1384

Php default timezone in sql query

I have this php to set the default timezone on my website:

<?php date_default_timezone_set('Europe/London'); ?>

It works fine if I use <?php echo date("Y-m-d"); ?> etc...

But I am running sql queries that say:

SELECT * from billing_pdf_archive where datetime < DATE(NOW() - INTERVAL 14 DAY)

How can u get the correct timezone for this too?

Upvotes: 0

Views: 199

Answers (1)

Vincent
Vincent

Reputation: 555

Or if you don't have admin access to mysql you can actually pass the php current date to replace the SQL NOW() function.

"SELECT * from billing_pdf_archive where datetime < DATE(".date('Y-m-d')." - INTERVAL 14 DAY)"

Upvotes: 1

Related Questions