Title: Small problem with timezone in a function
Last modified: April 30, 2020

---

# Small problem with timezone in a function

 *  Resolved Anonymous User 17836910
 * (@anonymized-17836910)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/small-problem-with-timezone-in-a-function/)
 * 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
    -  This topic was modified 6 years, 1 month ago by [Jan Dembowski](https://wordpress.org/support/users/jdembowski/).

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Suman](https://wordpress.org/support/users/sumanm/)
 * (@sumanm)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/small-problem-with-timezone-in-a-function/#post-12752125)
 * @diego92v
 * try using [https://wordpress.stackexchange.com/questions/227282/convert-time-to-wordpress-users-local-time](https://wordpress.stackexchange.com/questions/227282/convert-time-to-wordpress-users-local-time)
 *  Thread Starter Anonymous User 17836910
 * (@anonymized-17836910)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/small-problem-with-timezone-in-a-function/#post-12752298)
 * [@sumanm](https://wordpress.org/support/users/sumanm/) Thanks.
 * I tried it and the function doesn’t work well at all (or this code is too for
   me), one time added a weird colum of numbers and the other a 1970 date.
 * I think I can work perfectly with the Universal Time in this case.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Small problem with timezone in a function’ is closed to new replies.

## Tags

 * [date_i18n](https://wordpress.org/support/topic-tag/date_i18n/)
 * [time and date](https://wordpress.org/support/topic-tag/time-and-date/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 2 participants
 * Last reply from: Anonymous User 17836910
 * Last activity: [6 years, 1 month ago](https://wordpress.org/support/topic/small-problem-with-timezone-in-a-function/#post-12752298)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
