string-to-date

    1.0.0 • Public • Published

    About:

    Function "stringToDate" parse string. It returns object of Date. If format or date are invalid then it returns null.

    Example:

    import { stringToDate } from 'string-to-date'
     
    const date = stringToDate('2018-02-13 10:22:35')
     
    console.log(date instanceof Date) //true
    console.log(date.getFullYear()) //2018
    console.log(date.getMonth()) //1
    console.log(date.getDate()) //13
    console.log(date.getHours()) //10
    console.log(date.getMinutes()) //22
    console.log(date.getSeconds()) //35
     
    console.log(stringToDate('qwerty')) //null

    Params:

    Name Type Default
    date string
    format string YYYY-MM-DD HH:mm:ss

    Keywords

    none

    Install

    npm i string-to-date

    DownloadsWeekly Downloads

    86

    Version

    1.0.0

    License

    ISC

    Unpacked Size

    4.35 kB

    Total Files

    10

    Last publish

    Collaborators

    • gothic-prince