Code Monkey home page Code Monkey logo

Comments (4)

chriso avatar chriso commented on May 23, 2024

As in unix timestamp to a Javascript Date object? Or a full blown strptime implementation? A unix timestamp to Date object would be easy:

var toDate = function (timestamp) {
    return new Date(parseInt(timestamp, 10) * 1000);
}

from validator.js.

guileen avatar guileen commented on May 23, 2024

Thanks. it is a problem for the format of date.

I just create a project node-iform, base on node-validator. I hope you can take a look that.

from validator.js.

chriso avatar chriso commented on May 23, 2024

I'd say it's outside the scope of the library, but you can have a look at moment.js which might have the date parsing/formatting functionality you're looking for. I'll take a look at node-iform - nice to see validator out in the wild.

from validator.js.

chesles avatar chesles commented on May 23, 2024

A simple "toDate" that calls new Date(this.str) would be handy in Filter. Date.parse or new Date in node already handle some parsing:

> new Date('Jan 27, 2011')
Thu Jan 27 2011 00:00:00 GMT-0700 (MST)
> new Date(1296111600000)
Thu Jan 27 2011 00:00:00 GMT-0700 (MST)

Maybe a quick check to see if the input is all-numeric (as in the case of "1296111600000"), since passing that as a string returns an Invalid Date.

from validator.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.