• Resolved Anonymous User 17836910

    (@anonymized-17836910)


    Hello,

    I am having problems with the code of a function which should display the last login time and hour of a user.

    I realised the time is two hours ealier than my timezone.

    For example:

    – My last login was at Mércores, 29 de Abril de 2020, 7:58:13 a.m. but displays in admin panel: Mércores, 29 de Abril de 2020, 5:58:13 a.m.

    The code I used:

    function columna_ultimo_inicio_sesion( $output, $column_id, $user_id ){
        
    	if( $column_id == 'last_login' ) {
    		$last_login = get_user_meta( $user_id, 'last_login', true );
    		$date_format = 'l, j \d\e F \d\e Y, g:i:s a' ;
    		$output = $last_login ? date_i18n( $date_format, $last_login ) : '----------';
     	}
     	return $output;
    }
    
    add_action( 'wp_login', 'ultimo_inicio_sesion', 20, 2 );

    Do you have a moment?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Small problem with timezone in a function’ is closed to new replies.