Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Post time

 
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

The time of posting shows the server time.
Even though server is in different geographical location,is it possible to set it to indian time?

otherwise can I set the client time as the time of posting?
So which part of the code i should look into?

Thanks,
Razia
[originally posted on jforum.net by razia]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can take a look at net/jforum/view/forum/PostAction.java, method insertSave(). There you'll find a call to setPostTime() somewhere.

Rafael
[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply.

in net/jforum/view/forum/PostAction.java, method insertSave(),

inside if (newTopic) { ///code

I replaced t.setTime(new Date()) with

TimeZone timeZone = TimeZone.getTimeZone("Asia/Calcutta");

Date date = Calendar.getInstance(timeZone, Locale.US).getTime();
t.setTime(date);

and also in /jforum/view/forum/PostCommon.java in method Post fillPostFromRequest()
I replaced p.setTime(new Date()); with

TimeZone timeZone = TimeZone.getTimeZone("Asia/Calcutta");

Date date = Calendar.getInstance(timeZone, Locale.US).getTime();
p.setTime(date);

.....
But it didn't work.
When I wrote the code as standalone java application i got my system time.


..........
in generic_queries.sql

It is given
PostModel.addNewPost = INSERT INTO jforum_posts (topic_id, forum_id, user_id, post_time, poster_ip, enable_bbcode, enable_html, enable_smilies, enable_sig, post_edit_time, need_moderate) \
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), ?)


So, Does this mean post time is fetched in the query level by using now() function?

In that case how to manipulate this?

Thanks
Razia

[originally posted on jforum.net by razia]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The times in most of the jForum schema's are DateTime. For most SQL servers this is like Java's Date object. It's just a big integer number that is the millisecs or secs since some base GMT date.

Even if the server time is set to US Eastern Time and you are in India, Now() is still the same integer number.

So, IMHO, the problem is not in the STORING of the date, but in the DISPLAY of the date. DateFormat objects that are created without either a locale or having a TimeZone set will use the JVM's default settings.

So this means that all the SimpleDateFormat instances will need to be tracked down and modified. Or, if you control the JVM on the server, you can probably modify the default locale via a start up parameter so you get the correct time.

Best way to deal with it is to have a default timezone and a user preference option. (Hmm, maybe the default should be settable at the category, forum level too?)
[originally posted on jforum.net by monroe]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic