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

docs: timezone - set default timezone #18

Merged
merged 1 commit into from
Sep 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
.idea

node_modules

Expand Down
4 changes: 3 additions & 1 deletion docs/plugin/timezone.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ id: timezone
title: Timezone
---

Timezone adds `dayjs.tz` `.tz` `.tz.guess` APIs to parse or display between time zones.
Timezone adds `dayjs.tz` `.tz` `.tz.guess` `.tz.setDefault` APIs to parse or display between time zones.

```javascript
var utc = require('dayjs/plugin/utc') // dependent on utc plugin
Expand All @@ -16,4 +16,6 @@ dayjs.tz("2014-06-01 12:00", "America/New_York")
dayjs("2014-06-01 12:00").tz("America/New_York")

dayjs.tz.guess()

dayjs.tz.setDefault("America/New_York")
```
27 changes: 27 additions & 0 deletions docs/timezone/set-default-timezone.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
id: set-default-timezone
title: Set Default Timezone
---

Change default timezone from local time zone to your custom timezone.

You can still custom a different timezone in a specific `dayjs` object.

@>Timezone
```javascript
dayjs.extend(utc)
dayjs.extend(timezone)

dayjs.tz.setDefault("America/New_York")

// The same behavior with dayjs.tz("2014-06-01 12:00", "America/New_York")
dayjs.tz("2014-06-01 12:00") // 2014-06-01T12:00:00-04:00

// use another timezone
dayjs.tz("2014-06-01 12:00", "Asia/Tokyo") // 2014-06-01T12:00:00+09:00

// reset timezone
dayjs.tz.setDefault()
```

Notice: `dayjs.tz.setDefault` will not affect existing `dayjs` objects.
3 changes: 2 additions & 1 deletion website/sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@
"timezone/timezone",
"timezone/parsing-in-zone",
"timezone/converting-to-zone",
"timezone/guessing-user-timezone"
"timezone/guessing-user-timezone",
"timezone/set-default-timezone"
]
},
"docs-other": {
Expand Down