Results 1 to 3 of 3

Thread: Now() function does not reflect now

  1. #1
    Join Date
    Jul 2003
    Location
    Southern California
    Posts
    3

    Now() function does not reflect now

    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?

  2. #2
    Join Date
    Feb 2003
    Location
    Johannesburg, South Africa
    Posts
    145
    If you are using a Unix system, run the following script on the database server:

    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 output should look something like this:

    Code:
    $ perl test.pl 
    MySQL NOW() returned : 1062839545
    Perl Time Stamp : 1062839545
    The time stamps should not differ with more then one second. If it does, I suspect something wrong with MySQL.

    Cheers

  3. #3
    Join Date
    Sep 2003
    Posts
    1
    Now() gives time that is on the server,
    if you are not selecting from the server, time might be different

    A>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •