Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

[fORM] How to use fTiemstamps with fORM?

posted by istvan.m.antal 9 years ago

I have a database, I am trying to use fORM instead of writing queries, I have a table where I have a timestamps column, how do I express the NOW() - 5 minutes in fORM? I have tried this:

$ts = new fTimestamp('now');
$ts->adjust('-5 minutes');
$users = fRecordSet::build('User', array('remind_login_time>' => $ts));

This didn't work, it asked for my timezone in PHP, but I want to avoid using PHP for time operations, I want this to use MySQL to manage that for me. How can I make a value that would expand to NOW() and friends?

The simple answer is that you will have to write raw SQL if you want to do date manipulation inside of MySQL.

For the majority of web development, using a date from PHP should be more than satisfactory. Both MySQL and PHP base their times off of the system time, all you need to do is make sure they are both using the same default timezone. It looks like in MySQL you can get the system and connection timezones by executing SELECT @@global.time_zone, @@session.time_zone;. Then simply call date_default_timezone_set() in PHP and pass in the timezone.

posted by wbond 9 years ago