1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-11 16:22:26 +08:00

feat: add NowDateOrTime

This commit is contained in:
dudaodong
2023-07-26 15:03:59 +08:00
parent 31e8b12674
commit 326e7881a6
4 changed files with 110 additions and 0 deletions

View File

@@ -60,6 +60,7 @@ import (
- [BetweenSeconds](#BetweenSeconds)
- [DayOfYear](#DayOfYear)
- [IsWeekend](#IsWeekend)
- [NowDateOrTime](#NowDateOrTime)
<div STYLE="page-break-after: always;"></div>
@@ -1305,3 +1306,37 @@ func main() {
// false
}
```
### <span id="NowDateOrTime">NowDateOrTime</span>
<p>Return current datetime with specific format and timezone.</p>
<b>Signature:</b>
```go
func NowDateOrTime(format string, timezone ...string) string
```
<b>Example:</b>
```go
package main
import (
"fmt"
"github.com/duke-git/lancet/v2/datetime"
)
func main() {
result1 := datetime.NowDateOrTime("yyyy-mm-dd hh:mm:ss")
result2 := datetime.NowDateOrTime("yyyy-mm-dd hh:mm:ss", "EST")
fmt.Println(result1)
fmt.Println(result2)
// Output:
// 2023-07-26 15:01:30
// 2023-07-26 02:01:30
}
```