dromara / carbon

A simple, semantic and developer-friendly golang package for time
https://pkg.go.dev/github.com/golang-module/carbon/v2
MIT License
4.77k stars 238 forks source link

Why is this formatting different from the stdlib? #238

Closed rew1nter closed 4 months ago

rew1nter commented 4 months ago

Carbon here is not even formatting. Aren't these supposed to print out the same results?

package main

import (
    "fmt"
    "time"

    "github.com/golang-module/carbon/v2"
)

func main() {
    blinkf := "2006-01-02T15:04:05.000Z07:00"
    fmt.Println(carbon.Now().Format(blinkf))
    // 2006-01-02+0615:04:05.000171894041852461633907:00
    fmt.Println(time.Now().Format(blinkf))
    // 2024-06-21T09:26:58.524+06:00
}
gouguoyin commented 4 months ago

Usage error, the correct one should be as follows

fmt.Println(carbon.Now().Layout(blinkf))
gouguoyin commented 4 months ago
fmt.Println(carbon.Now().Format("Y-m-d H:i:s"))
rew1nter commented 4 months ago

Got it. Thanks