Download the PHP package michaeldrennen/natural-date without Composer

On this page you can find all versions of the php package michaeldrennen/natural-date. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package natural-date

NaturalDate

Latest Stable Version Total Downloads License Build Status Coverage Status

When telling stories, people usually don't give an exact date for the events of the story. They often say things like:

the summer of '87

or

last Christmas

You can use NaturalDate to translate these date approximations to usable dates or date ranges in your code.

If NaturalDate can't determine an exact date from the input, it will give you a start and end date that the actual date should be between.

Example

Output

{  
  "utcStart": {  
    "date": "2016-01-01 07:00:00.000000",  
    "timezone_type": 3,  
    "timezone": "UTC"  
  },  
  "utcEnd": {  
    "date": "2016-05-01 05:59:59.000000",  
    "timezone_type": 3,  
    "timezone": "UTC"  
  },  
  "localStart": {  
    "date": "2016-01-01 00:00:00.000000",  
    "timezone_type": 3,  
    "timezone": "America\/Denver"  
  },  
  "localEnd": {  
    "date": "2016-04-30 23:59:59.000000",  
    "timezone_type": 3,  
    "timezone": "America\/Denver"  
  }  
}

Summary of Functions

parse( string $string = '', string $timezoneId = 'UTC', string $languageCode = 'en', $patternModifiers = [], NaturalDate $existingNaturalDate = NULL, bool $cleanOutput = TRUE ): NaturalDate

Explaining the parameters:

getLocalStart()

This method returns a Carbon object with the user's timezone. The Carbon object represents when NaturalDate thinks the earliest possible time was based on the user's input.

getLocalEnd()

This method returns a Carbon object with the user's timezone. The Carbon object represents when NaturalDate thinks the latest possible time was based on the user's input.

getUtcStart() and getUtcEnd()

These methods act the same as getLocalStart() and getLocalEnd() but the Carbon objects they return use the UTC timezone.

getType()

This method will return a string that gives you an idea of the "confidence" that NaturalDate has on the data it's returning to you.

Possible values are:

toJson()

For convenience, I've added a toJson() method that returns the NaturalDate object created by NaturalDate::parse() in a json encoded string.

__toString()

I also created an implementation of the magic __toString() method, so if you echo the NaturalDate object, you will get a prettified output describing the NaturalDate object.

Missing holidays? Just ask for them.

If you see that NaturalDate is missing some holidays (it is), create an issue on GitHub and I will add them. Holidays from all countries should be part of the base library.

Building onto the PatternModifiers

This is the really cool thing. You can create your own PatternModifiers. What does that mean exactly?

Think about this scenario... You want to let your users enter a date like: "my freshman year in high school"

Well obviously NaturalDate doesn't know when that is. So you could create your own PatternModifier to pass into the parse() method.

Your pattern modifier would need a regular expression that would trigger it, and dates to fill in when triggered.

Use the class named JohnMcClanesBirthday in the PatternModifiers directory as a model.

It should be pretty easy for you to copy that and modify it to suit your needs.


All versions of natural-date with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3|^8.0
nesbot/carbon Version ^2.0
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package michaeldrennen/natural-date contains the following files

Loading the files please wait ....