1.0.1 • Published 2 years ago

@xyan/xtime v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

functions

functionparamsdescription
toStringargs = 'yyyy-MM-dd HH:mm:ss'format a datetime to string
addDaysvalueadd days to time, return a new instance
addHoursvalueadd hours to time, return a new instance
addMinitesvalueadd minites to time, return a new instance
unixTimeStamp-return unix timestamp
totalDayOfMonth-return total days of month
firstDayOfWeek-return the first day of current week
lastDayOfWeek-return the last day of current week
firstDayOfMonth-return the first day of current month
lastDayOfMonth-return the last day of current month
setTimeToDayStart-set time to day start
setTimeToDayEnd-set time to day end

usage

import xtime from '@xyan/xtime'
var time = new xtime()
time.toString() // 2022-01-21 18:27:27
time.toString(xtime.format.date) // 2022-01-21
time.toString(xtime.format.time) // 14:53:25
time.toString(xtime.format.dateTime) // 2022-01-21 18:27:27
time.toString(xtime.format.UTCDateTime) // 2022-01-21T10:27:27Z
time.addDays(1) // 2022-01-22 18:27:27
time.addHours(1) // 2022-01-21 19:27:27
time.addMinites(1) // 2022-01-21 18:28:27
time.unixTimeStamp() // 1642760847
time.totalDayOfMonth() // 31
time.firstDayOfWeek() // 2022-01-17 18:27:27
time.lastDayOfWeek() // 2022-01-23 18:27:27
time.firstDayOfMonth() // 2022-01-01 18:27:27
time.lastDayOfMonth() // 2022-01-31 18:27:27
time.setTimeToDayStart() // 2022-01-21 00:00:00
time.setTimeToDayEnd() // 2022-01-21 23:59:59