LittleJack has asked for the wisdom of the Perl Monks concerning the following question:
I have a working DBIx::Class resultset which looks roughly like this:
my $tasks_to_do = $self->search( { -and => [ scheduled_run_time => { '<= +', 'NOW()'}, status => 'pending' ] } );
But I need that "NOW()" to be in Sydney, Australia time, not the server time which is UTC.
In the script which calls this ResultSet method I've got both
BEGIN { $ENV{TZ} = 'Australia/Sydney'; }
and
$schema->storage->dbh_do(sub {"SET TIMEZONE='Australia/Sydney'"} );
But it still returns no records.
Due diligence: I know there are records because if I go in to the db manually and do this:
sessions=> SET TIMEZONE='UTC'; SET sessions=> select * from mytable where scheduled_run_time <= NOW() and + status = 'pending';
I get "no rows", but if I do this:
sessions=> SET TIMEZONE='Australia/Sydney'; SET sessions=> select * from mytable where scheduled_run_time <= NOW() and + status = 'pending';
I get the expected number of records.
TIA. I have had my coffee by the way.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to use the right timezone in a DBIx::Class ResultSet call?
by Your Mother (Archbishop) on Aug 09, 2022 at 06:51 UTC | |
by LittleJack (Beadle) on Aug 11, 2022 at 22:45 UTC | |
by Your Mother (Archbishop) on Aug 12, 2022 at 01:14 UTC |
Back to
Seekers of Perl Wisdom