Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how do I change the default timezone? #66

Closed
smilence86 opened this issue Jun 2, 2015 · 5 comments
Closed

how do I change the default timezone? #66

smilence86 opened this issue Jun 2, 2015 · 5 comments
Assignees
Labels

Comments

@smilence86
Copy link

I found the default timezone is "+0000" in output log on my servers, How do I change the timezone?
example, change to: 02/Jun/2015:08:06:14 +0300
who know it? please help me, thanks~

@chk-
Copy link

chk- commented Jun 2, 2015

I just came across the same issue.
@dougwilson wrote in issue #21 -> #13 "...all logs are in UTC because it is an absolute standard."
I don't think so and found Wikipedia - Common_Log_Format and others.
However, a workaround was also posted at #13 (new Date().toString()) But the output is not the clfdate format!
In principle there is the possibility to use a custom token for that. I show my personal solution:

morgan.token('date', function() {
    var p = new Date().toString().replace(/[A-Z]{3}\+/,'+').split(/ /);
    return( p[2]+'/'+p[1]+'/'+p[3]+':'+p[4]+' '+p[5] );
});

@dougwilson dougwilson self-assigned this Jun 2, 2015
@dougwilson
Copy link
Contributor

Yes, defining a custom token is the way to change it (which is why you can define tokens).

@smilence86
Copy link
Author

Okay, thanks~ I have resolved.

@zhanbei
Copy link

zhanbei commented Apr 22, 2018

Is the :date[clf] supposed to use server timezone like the -0700 in [10/Oct/2000:13:55:36 -0700] from Wikipedia - Common_Log_Format?

It seems to be yes, which I do think should be stated in the README.md file to make it clear.

What do you think? Thanks.

@dougwilson
Copy link
Contributor

All the dates from the :date token are in UTC, as stated in the README:

The current date and time in UTC. The available formats are:

The formats just present the date and time differently, but they are all in the UTC time zone as documented.

@expressjs expressjs locked as resolved and limited conversation to collaborators Apr 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants