Get last accessed timestamp value of a user in Drupal 8 Im trying to display the last accessed field when a user logs in. 
For this I tried using User::getLastLoginTime() .
But this returns a fatal error saying 

PHP Fatal error:  Call to undefined method Drupal\customize_block\Plugin\Block\ContractDetails::get() in /var/www/html/core/modules/user/src/Entity/User.php on line 265

Here is my block ,in my custom module:

/**
 * Provides a 'Customized contract' Block
 *
 * @Block(
 *   id = "customer_info",
 *   label = @Translation("Customer and contract info"),
 *   module = "user",
 *   context = {
 *     "current_user" = @ContextDefinition("entity:user", label = @Translation("Current User"))
 *   }
 * )
namespace Drupal\customize_block\Plugin\Block;

use Drupal\Core\Block\BlockBase;

class ContractInfo extends BlockBase {
 public function build() {
 $output='';
 global $base_url;
 $current_user = $this-&gt;getContext('current_user');
 $output.='&lt;div&gt;' . $current_user -&gt; contextData . '&lt;/div&gt;';

     return array(
      '#markup' =&gt; $output,
      '#cache' =&gt; array(
     'contexts' =&gt; array('url'),
      ),
    );
  }
}


Am I calling this method correct way?
getLastLoginTime is not a static method so you would not be able to call it statically like that. You need to get the current user object from a couple of different ways:

1. Use the Drupal::currentUser.

This is easy, but not recommended to tightly-couple your block.

2. Inject the current_user service into your Block by implementing ContainerFactoryPluginInterface.

The disadvantage is that this also has a dependency on the container, but can be mocked.

3. Use the Context system because blocks extend ContextAwarePluginBase.

This is the recommended option in my opinion because there is already a current user context (as well as node contexts) for blocks.

 * @Block(
 *   ...
 *   context = {
 *     "current_user" = @ContextDefinition("type" = "entity:user", "label" =&gt; @Translation("Current User")
 *   }
 * )


Then $current_user = $this-&gt;getContext('current_user') will get the current user.

Unfortunately there is not a handbook page about using contexts so documentation is relegated to guessing things based on the change record, which itself was no longer accurate at the time of writing this answer.

Interestingly some IDEs (cough PhpStorm 10 cough) choke on the above annotation syntax because.

Finally...

You should look at the documentation for render arrays and the changes to make markup safe.