Self Date.from_string (String str) vs. 1.1.0 Full+Lite

Create a date from a given string. The string should be a valid date in a commen format.

Parameters

String str Required vs. 1.1.0 Full+Lite
A date formatted string. If the date can't be parsed using Date.parse() a list of custom values are provided below. All custom values are relative to the date object.
  • Any string that can be parsed by Date.parse()
    • Short dates can use either back slash, forward slash or a dash as a separator, but must follow the month/day/year format, for example "7/20/96". month are 1 for January 12 for December
    • Long dates of the form "July 10 1995" can be given with the year, month, and day in any order, and the year in 2-digit or 4-digit form. If you use the 2-digit form, the year must be greater than or equal to 70.
    • Month and day names must have two or more characters. Two character names that are not unique are resolved as the last match. For example, "Ju" is resolved as July, not June.
    • Handles all standard time zones, as well as Universal Coordinated Time (UTC) and Greenwich Mean Time (GMT).
    • Colons separate hours, minutes, and seconds, although all need not be specified. "10:", "10:11", and "10:11:12" are all valid.
    • If the 24-hour clock is used, it is an error to specify "PM" for times later than 12 noon. For example, "23:15 PM" is an error.
    • A string containing an invalid date is an error. For example, a string containing two years or two months is an error.
       
  • All the following values are relative to the initial date. For example, the code below will be Feb 1st, 2004.
    new Date(2004, 1, 1).from_string('today');
    • "today" return the current date
    • "yesterday" a day before
    • "tomorrow" a day after
    • "today+[n]" go forward [n] number of days. [n] is a numeric value (e.g. today+5).
    • "today-[n]" go back [n] number of days
    • "last month" go back a month
    • "next month" go forward a month
    • "month+[n]" go forward ]n] number of months
    • "month-[n]" go back [n] number of months
    • "last year" go back one year
    • "next year" go forward one year
    • "year+[n]" go forward [n] number of years
    • "year-[n]" go back [n] number of years

Return

Self Required vs. 1.1.0 Full+Lite
The original date modified based on the passed string.

Examples

Using Date.from_string(str)
Demo: