Skip to content

Utils

I. DateTime

formatDate

Usage

import { formatDate } from 'v99-kits'

Example

var currentDate = formatDate({ dateTime: new Date(), format: 'DD/MM/yyyy' })

console.log(currentDate)

==> 14/08/2023

getDiffTime

Usage

import { getDiffTime } from 'v99-kits'

Example

var diffTime = getDiffTime(
    new Date(2023, 8, 14, 15),
    new Date(2023, 8, 14, 13),
)

console.log(diffTime)

==> 7200

getDiffTimeFromNow

Usage

import { getDiffTimeFromNow } from 'v99-kits'

Example

var diffTime = getDiffTimeFromNow(
    new Date(2023, 7, 14, 18)
)

console.log(diffTime)

==> 5497

startDateWeek

Usage

import { startDateWeek } from 'v99-kits'

Example

var startDate = startDateWeek()

console.log(startDate)

==> 2023-08-13T17:00:00.000Z 

subtractDayFromToDay

Usage

import { subtractDayFromToDay } from 'v99-kits'

Example

var date = subtractDayFromToDay(1)

console.log(date)

==> 2023-08-13T09:36:46.366Z 

isSameDate

Usage

import { isSameDate } from 'v99-kits'

Example

var isSame = isSameDate(
    new Date(2023, 8, 14, 15),
    new Date(2023, 8, 14, 13),
)

console.log(isSame)

==> true

II. Device

isAndroid

Usage

import { isAndroid } from 'v99-kits'

Example

console.log(isAndroid)

==> false

isIOS

Usage

import { isIOS } from 'v99-kits'

Example

console.log(isIOS)

==> true

III. Number

getRandomInt

Usage

import { getRandomInt } from 'v99-kits'

Example

var random = getRandomInt(10, 100)
console.log(random)

==> 25

formatNumberToPercent

Usage

import { formatNumberToPercent } from 'v99-kits'

Example

var random = formatNumberToPercent(10)
console.log(random)

==> '10%'

roundNumber

Usage

import { roundNumber } from 'v99-kits'

Example

var round = roundNumber(5)
console.log(round)

==> '05'

var round = roundNumber(15)
console.log(round)

==> 15

formatBankCardNumber

Usage

import { formatBankCardNumber } from 'v99-kits'

Example

var bankCardNumber = formatBankCardNumber('123456789123')
console.log(bankCardNumber)

==> '1234 5678 9123'

formatBankCardNumber

Usage

import { formatBankCardNumber } from 'v99-kits'

Example

var bankCardNumber = formatBankCardNumber('123456789123')
console.log(bankCardNumber)

==> '1234 5678 9123'

formatNumberToMoney

Usage

import { formatNumberToMoney } from 'v99-kits'

Example

var money = formatNumberToMoney(123, '$')
console.log(money)

==> '123 $'

formatCurrencyToNumber

Usage

import { formatCurrencyToNumber } from 'v99-kits'

Example

var number = formatCurrencyToNumber('123$')
console.log(number)

==> 123

formatPhoneNumberVN

Usage

import { formatPhoneNumberVN } from 'v99-kits'

Example

var phone = formatPhoneNumberVN('123456789')
console.log(phone)

==> '0123456789'

IV. String

removeAlias

Usage

import { removeAlias } from 'v99-kits'

Example

var text = removeAlias('chuyển tiền')
console.log(text)

==> 'chuyen tien'