フォーラム

ホーム » Liferay Portal » English » 2. Using Liferay » General

構造的に表示 平面上に表示 ツリー上に表示
スレッド [ 前へ | 次へ ]
toggle
Ryan Terwedo
User login information - When a user last logged in
2010/11/17 17:59
答え

Ryan Terwedo

ランク: Junior Member

投稿: 93

参加年月日: 2008/10/30

最近の投稿

Is there a way to see when a user last logged in or even better, a trail of all their login s?

I have poked around and unless the words I aanm searching for are wrong, I cannot find anything.

Thanks,

Ryan
Amos Fong
RE: User login information - When a user last logged in
2010/11/17 19:08
答え

Amos Fong

LIFERAY STAFF

ランク: Liferay Legend

投稿: 1844

参加年月日: 2008/10/07

最近の投稿

Hey Ryan,

If you have the user object you can use this method:
1
2    public Date getLastLoginDate() {
3        return _lastLoginDate;
4    }


I don't think a history is kept anywhere though.
Ryan Terwedo
RE: User login information - When a user last logged in
2010/12/17 8:52
答え

Ryan Terwedo

ランク: Junior Member

投稿: 93

参加年月日: 2008/10/30

最近の投稿

Thanks... I have no idea where I would use that (Its been forever since I coded). Any help on where this would go?

Thanks!!
Sandeep Nair
RE: User login information - When a user last logged in
2010/12/17 9:11
答え

Sandeep Nair

ランク: Liferay Legend

投稿: 1692

参加年月日: 2008/11/05

最近の投稿

Hi,

As Amos said you can just retrieve only the lastloginDate of the user

If you want to find the login date of the logged in user simply use the following

PortalUtil.getUser(request).getLastLoginDate();

If you want loginDate of all users, u can call UserLocalServiceUtil.getUsers(-1,-1);
to retrieve all users in system and then use the above method in a loop.
Marcus Souza
RE: User login information - When a user last logged in
2011/01/10 8:14
答え

Marcus Souza

ランク: Junior Member

投稿: 58

参加年月日: 2009/03/31

最近の投稿

Sandeep Nair:
Hi,

As Amos said you can just retrieve only the lastloginDate of the user

If you want to find the login date of the logged in user simply use the following

PortalUtil.getUser(request).getLastLoginDate();

If you want loginDate of all users, u can call UserLocalServiceUtil.getUsers(-1,-1);
to retrieve all users in system and then use the above method in a loop.


I am trying the same thing in a VM File
with the code

$user.getLastLoginDate() --> Mon Jan 10 16:11:47 GMT 2011

I get it, but i cant format or split it

I tried

$splittedLoginDate = $stringUtil.split($user.getLoginDate(), ' ')
$date.format('medium',$user.getLoginDate())

but i get just the same string. can someone pls point me in the right direction?

Marcus
Sandeep Nair
RE: User login information - When a user last logged in
2011/01/10 9:02
答え

Sandeep Nair

ランク: Liferay Legend

投稿: 1692

参加年月日: 2008/11/05

最近の投稿

You can use date variable to format. For example if you want to get year from date u could use something as

$date.getDate($user.getLoginDate(),"yyyy", $locale)

The above will give you year in your case 2011
Marcus Souza
RE: User login information - When a user last logged in
2011/01/11 0:20
答え

Marcus Souza

ランク: Junior Member

投稿: 58

参加年月日: 2009/03/31

最近の投稿

It works. Thanks a lot Sandeep. Where are the library with all methodes? then I dont need to ask next time.
Marcus
Sandeep Nair
RE: User login information - When a user last logged in
2011/01/11 1:26
答え

Sandeep Nair

ランク: Liferay Legend

投稿: 1692

参加年月日: 2008/11/05

最近の投稿

Actually i am not aware. Basically what i do is i know all the variables that used in vm files are put using VelocityVariable. So i just dig Velocity Variables and then see the init.vm of unstyled theme to see, to which variable is it assigned to.
Ken Patrick
RE: User login information - When a user last logged in
2012/04/20 8:33
答え

Ken Patrick

ランク: New Member

投稿: 9

参加年月日: 2011/11/02

最近の投稿

Sandeep Nair:
Actually i am not aware. Basically what i do is i know all the variables that used in vm files are put using VelocityVariable. So i just dig Velocity Variables and then see the init.vm of unstyled theme to see, to which variable is it assigned to.



I can't figure out how to get the month at all, I have it set as:

1$date.getDate($user.getLoginDate(),"dd", $locale)/$date.getDate($user.getLoginDate(),"mm", $locale)/$date.getDate($user.getLoginDate(),"yyyy", $locale)


however that gets me an odd date:

20/53/2012
David H Nebinger
RE: User login information - When a user last logged in
2012/04/20 9:24
答え

David H Nebinger

ランク: Liferay Legend

投稿: 7080

参加年月日: 2006/09/01

最近の投稿

'mm' is minute, 'MM' is month.
Ken Patrick
RE: User login information - When a user last logged in
2012/04/20 10:37
答え

Ken Patrick

ランク: New Member

投稿: 9

参加年月日: 2011/11/02

最近の投稿

thank you!
Chethan Barike
RE: User login information - When a user last logged in
2012/11/13 23:17
答え

Chethan Barike

ランク: Junior Member

投稿: 28

参加年月日: 2012/03/27

最近の投稿

Hi Ken Patrick,

use in this way -- $date.getDate($user.getLastLoginDate(),"dd-MM-yyyy hh:mm:ss",$locale)

Ken Patrick:

I can't figure out how to get the month at all, I have it set as:
1$date.getDate($user.getLoginDate(),"dd", $locale)/$date.getDate($user.getLoginDate(),"mm", $locale)/$date.getDate($user.getLoginDate(),"yyyy", $locale)

however that gets me an odd date:
20/53/2012


BR,
Chethan
Steve Cochran
RE: User login information - When a user last logged in
2012/11/16 14:22
答え

Steve Cochran

ランク: New Member

投稿: 13

参加年月日: 2012/08/21

最近の投稿

Anyone know if it possible to see this through the control panel GUI?