Skip to content

Commit c7a951a

Browse files
committed
docs: Added date format docs
1 parent e65c755 commit c7a951a

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ If the `theme` parameter is specified, any color customizations specified will b
6161
| Parameter | Details | Example |
6262
| :---------------: | :--------------------------------------------: | :---------------------------------------------------: |
6363
| `user` | GitHub username to show stats for | `DenverCoder1` |
64+
| `date_format` | Date format (Default: `M j[, Y]`) | See note below on format strings |
6465
| `theme` | The theme to apply (Default: `default`) | `dark`, `radical`, etc. [🎨➜](./docs/themes/README.md) |
6566
| `hide_border` | Make the border transparent (Default: `false`) | `true` or `false` |
6667
| `background` | Background color | **hex code** without `#` or **css color** |
@@ -75,11 +76,22 @@ If the `theme` parameter is specified, any color customizations specified will b
7576
| `dates` | Date range text color | **hex code** without `#` or **css color** |
7677
| `type` | Output format (Default: `svg`) | Current options: `svg` or `json` |
7778

78-
### Example
79+
### Date Formats
7980

80-
```md
81-
[![GitHub Streak](https://github-readme-streak-stats.herokuapp.com/?user=denvercoder1&currStreakNum=2FD3EB&fire=pink&sideLabels=F00)](https://git.io/streak-stats)
82-
```
81+
A custom date format can be specified by passing a string to the `date_format` parameter.
82+
83+
The required format is to use format string characters from [PHP's date function](https://www.php.net/manual/en/datetime.format.php) with brackets around the part representing the year.
84+
85+
When the contribution year is equal to the current year, the characters in brackets will be omitted.
86+
87+
**Examples:**
88+
89+
| Date Format | Result |
90+
| :-----------------: | :-----------------------------------------------------------------------------: |
91+
| <pre>d F[, Y]</pre> | <pre>"2020-04-14" => "14 April, 2020"<br/><br/>"2021-04-14" => "14 April"</pre> |
92+
| <pre>j/n/Y</pre> | <pre>"2020-04-14" => "14/4/2020"<br/><br/>"2021-04-14" => "14/4/2021"</pre> |
93+
| <pre>[Y.]n.j</pre> | <pre>"2020-04-14" => "2020.4.14"<br/><br/>"2021-04-14" => "4.14"</pre> |
94+
| <pre>M j[, Y]</pre> | <pre>"2020-04-14" => "Apr 14, 2020"<br/><br/>"2021-04-14" => "Apr 14"</pre> |
8395

8496
## ℹ️ How these stats are calculated
8597

0 commit comments

Comments
 (0)