carbon

package
v0.5.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Nanosecond  = time.Nanosecond
	Microsecond = 1000 * Nanosecond
	Millisecond = 1000 * Microsecond
	Second      = 1000 * Millisecond
	Minute      = 60 * Second
	Hour        = 60 * Minute
	Day         = 24 * Hour
	Week        = 7 * Day
)

Variables

View Source
var (
	Shanghai, _ = time.LoadLocation("Asia/Shanghai")
)

Functions

func In

func In(loc *time.Location)

设置全局时区

Types

type Carbon

type Carbon struct {
	// contains filtered or unexported fields
}

Carbon

func Now

func Now() *Carbon

func Parse

func Parse(str string) *Carbon

todo alias to StrOf

func StrOf

func StrOf(str string) *Carbon

解析时间文本

func TParse

func TParse(layout, value string) *Carbon

wrap of time.Parse but with the carbon layout 使用 Go time.Time 解析时间文本

func TimeOf

func TimeOf(t time.Time) *Carbon

func UnixOf

func UnixOf(sec int64, nsec int64) *Carbon

func (Carbon) Add

func (c Carbon) Add(d time.Duration) *Carbon

func (*Carbon) Clone

func (c *Carbon) Clone() *Carbon

func (*Carbon) Format

func (c *Carbon) Format(format string) string

Format 格式化代码 c.Format("Y-m-d H:i:s") @see http://php.net/manual/zh/function.date.php#refsect1-function.date-parameters

func (Carbon) In

func (c Carbon) In(loc *time.Location) *Carbon

设置时区

func (Carbon) Sub

func (c Carbon) Sub(d time.Duration) *Carbon

减去一段时间

func (*Carbon) SubTime

func (c *Carbon) SubTime(t time.Time) time.Duration

减去另一个时间:计算两个时间的差

func (*Carbon) Time

func (c *Carbon) Time() time.Time

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL