Change Event time in Event log to GMT

giang le asked on August 4, 2014 12:02

Hi all!

I have a question: How to change Change Event time in Event log to GMT. Currently, Event time is current time of server(Datetime.Now). I tried find a few codes to Log and change Datetime.Now to Datetime.UtcNow.

log.LogEvent(eventType, DateTime.Now, source, eventCode, CMSContext.CurrentUser.UserID, HTTPHelper.GetUserName(), nodeId, nodeNamePath, HTTPHelper.UserHostAddress, eventDescription, siteId, HTTPHelper.GetAbsoluteUri());

to

log.LogEvent(eventType, DateTime.UtcNow, source, eventCode, CMSContext.CurrentUser.UserID, HTTPHelper.GetUserName(), nodeId, nodeNamePath, HTTPHelper.UserHostAddress, eventDescription, siteId, HTTPHelper.GetAbsoluteUri());

However, I thought I can't change every where because there are many place to implement log so please suggest for me best way.

Thank very much!

GiangLT3

Recent Answers


Brenden Kehren answered on August 4, 2014 14:24

You might check the setting and enable Time Zones. You can set the zone the server is in as well as what zone the site is in.

0 votesVote for this answer Mark as a Correct answer

giang le answered on August 5, 2014 13:05

Thank for your reply!

Can you explain your suggest?

I tried enable Time Zones in CMSSiteManager and set the zone for server. However, it still using my server' time(Date.Now) to log Event. Explain for my Question: - My server in US We want: - Client A from Canada access my site: Site will using UTC time of Canada for log Event. - Client B from France access my site: Site will using UTC time of France for log Event. Please help me!

Giang

0 votesVote for this answer Mark as a Correct answer

giang le answered on August 6, 2014 11:28

Please help meeee!

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on August 13, 2014 03:49

In Settings>System there is a property to enable time zones. Check it. Then set the timezone the server is in and set the timezone for the website. Users can update their profile to have a timezone then or you can set a default (which is the site I believe). So although its stored in one time, it will display to them in their desired zone.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.