Use current_time( 'timestamp' ) instead of time() to take into account site timezone.