Foros de discusión

Date

thumbnail
Umer Sayeed, modificado hace 11 años.

Date

Junior Member Mensajes: 51 Fecha de incorporación: 8/08/12 Mensajes recientes
Hi All ,

When i add new item in Shopping portlet, then in database CreateDate and ModifiedDate column date is comming correct but its taking 5hrs back time,suppose if a i add item at 6:00,in database its taking as 12:30.., please help how to solve this.

Thanks
thumbnail
David H Nebinger, modificado hace 11 años.

RE: Date

Liferay Legend Mensajes: 14916 Fecha de incorporación: 2/09/06 Mensajes recientes
There is nothing to resolve.

Liferay (as it should) stores dates/times in GMT mode. Users define the TZ they're in, and the GMT should be converted to the user's local time at presentation time.
thumbnail
mohiden abdul kader, modificado hace 11 años.

RE: Date

Junior Member Mensajes: 38 Fecha de incorporación: 8/08/12 Mensajes recientes
David H Nebinger:
There is nothing to resolve.

Liferay (as it should) stores dates/times in GMT mode. Users define the TZ they're in, and the GMT should be converted to the user's local time at presentation time.



Hi ,

I am also facing the same problem .Its not converting into local machine time,So Kindly give your valuable ideas..

Thanks Regards,
Abdul Kader
thumbnail
David H Nebinger, modificado hace 11 años.

RE: Date

Liferay Legend Mensajes: 14916 Fecha de incorporación: 2/09/06 Mensajes recientes
If you pull a date using SB, the date comes back to you as GMT.

From there you need to access the current user, find their selected TZ (it is directly accessible from the User pojo, getTimeZone()).

From there you'd define your DateFormat (for rendering), and set the timezone on the DateFormat to the user's TZ. When you call the format() method, it will give you a string with the date formatted for the user's timezone.

That's the hard way (all manual), but it works. An easier method would be:

DateFormat df = DateFormatFactoryUtil.getSimpleDateFormat("MM/dd/yyyy hh:mm", user.getTimeZone());

This will give you a date format w/ the timezone assigned that you can then use for rendering the date/time adjusted for each user.
thumbnail
Dave Weitzel, modificado hace 10 años.

RE: Date

Regular Member Mensajes: 208 Fecha de incorporación: 18/11/09 Mensajes recientes
hi David
Came across this post when checking on getting dates to display right for user timezones.
DateFormat df = DateFormatFactoryUtil.getSimpleDateFormat("MM/dd/yyyy hh:mm", user.getTimeZone());

is this still the preferred way of doing things?

I would have expected a tagLib to do this and detect if there is a user or not.

Our first multi timezone location is going live and so many dates are not showing right as everything is GMT!

Any new thoughts on this, does GA3 or 6.2 change things do you know?
thumbnail
Hitoshi Ozawa, modificado hace 11 años.

RE: Date

Liferay Legend Mensajes: 7942 Fecha de incorporación: 24/03/10 Mensajes recientes
If you're only going to be using in one time zone, just set user.timezone property in System-ext.properties.

I've seen some web systems do what liferay does on displaying time in user's timezone but this actually is very confusing because when there's an announcement that something is going to be on xxx date, it's difficult to know which timezone that means. If a timezone is given with the time, I still have to go check World Time page to see what time that is in my timezone.
thumbnail
David H Nebinger, modificado hace 11 años.

RE: Date

Liferay Legend Mensajes: 14916 Fecha de incorporación: 2/09/06 Mensajes recientes
We have users spread across the US. We display times in their timezone so they don't have to do the conversions in their heads or look at the world clock. We store our times in GMT so it's an easy one-way conversion. Using a non-GMT timezone, we'd have to convert between two different timezones, and that can get kinda messy (especially w/ DST stuff thrown in).
thumbnail
Hitoshi Ozawa, modificado hace 11 años.

RE: Date

Liferay Legend Mensajes: 7942 Fecha de incorporación: 24/03/10 Mensajes recientes
Yes, this is really a localization problem. Some of us only use 1 timezone and it's really confuses users. I think India is in 1 timezone too.
thumbnail
Umer Sayeed, modificado hace 11 años.

RE: Date

Junior Member Mensajes: 51 Fecha de incorporación: 8/08/12 Mensajes recientes
hi i found the solution, just write ASIA/KOLKATA in place of GMT in setenv.bat in tomcat server....,


Thanks and Regards,
Ummer