Skip to content

Converts a string to a date object written in Javascript. Accepts every string and returns the best possible guess to correct date, instead of matching to known date formats.

License

Notifications You must be signed in to change notification settings

liambolling/StringtoDate.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to StringToDate.js

I ran into an issue where my latest project needed to extract a date object from a wide range of strings that contained dates. From what I could find, there wasn’t a library that could take a string such as "The event is at July 23rd @ around 10:00”, so I created one that relies on patterns and individual pieces of information, as opposed to a large library of formats. This library will try its best to figure out the date you throw at it and I’ll be adding more natural language soon.

Example strings that StringToDate.js can take:

  • "The event is at July 23rd @ around 10:00" returns...
    Thu Jul 23 2015 10:00:54 GMT-0400 (EDT),Thu Jul 23 2015 10:00:54 GMT-0400 (EDT)
  • "I’ll meet you at Johns house at around 10:00PM on the 20th" returns...
    Wed May 20 2015 22:00:20 GMT-0400 (EDT),Wed May 20 2015 22:00:20 GMT-0400 (EDT)
  • "01.02.2016" returns Wed May 20 2015 22:00:20 GMT-0400 (EDT),Wed May 20 2015 22:00:20 GMT-0400 (EDT)
  • "Jul 17th at 7:00PM to July 19th @ 6:30AM" returns Fri Jul 17 2015 19:00:16 GMT-0400 (EDT),Sun Jul 19 2015 06:30:16 GMT-0400 (EDT)

If you decide to use this, or build off of it, just give me some credit 😀
Twitter - @liambolling
LinkedIn - https://www.linkedin.com/in/liambolling
Website - https://www.liambolling.com

About

Converts a string to a date object written in Javascript. Accepts every string and returns the best possible guess to correct date, instead of matching to known date formats.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published