The NOW() function is giving me a time which is not now. Where is the NOW data retrieved from? Is there anyway I can manage this information, as in adding a constant hour:min to the NOW data?
Printable View
The NOW() function is giving me a time which is not now. Where is the NOW data retrieved from? Is there anyway I can manage this information, as in adding a constant hour:min to the NOW data?
If you are using a Unix system, run the following script on the database server:
The output should look something like this:Code:#!/usr/bin/perl
use DBI;
$dbh = DBI->connect("dbi:mysql:test", "root", "" );
$sql = "SELECT UNIX_TIMESTAMP( NOW() )";
$sth = $dbh->prepare( $sql );
if ( $sth->execute() ) {
while( ( my $sqltime ) = $sth->fetchrow_array() ) {
print "MySQL NOW() returned : $sqltime\n";
}
}
$time = time();
print "Perl Time Stamp : $time\n";
exit;
The time stamps should not differ with more then one second. If it does, I suspect something wrong with MySQL.Code:$ perl test.pl
MySQL NOW() returned : 1062839545
Perl Time Stamp : 1062839545
Cheers
Now() gives time that is on the server,
if you are not selecting from the server, time might be different
A>