Download the PHP package fightbulc/moment without Composer

On this page you can find all versions of the php package fightbulc/moment. 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 moment

Support

I am a dad now for the last 1,5 years and that clearly shows in being on time with merging PRs or pushing this package further. Time is the biggest constraint here. I would be happy to pass the project on to somebody who has more time and the motivation to push the project forward. Just drop me a message. Cheers!

                                      _           _
 _ __ ___   ___  _ __ ___   ___ _ __ | |_   _ __ | |__  _ __
| '_ ` _ \ / _ \| '_ ` _ \ / _ \ '_ \| __| | '_ \| '_ \| '_ \
| | | | | | (_) | | | | | |  __/ | | | |_ _| |_) | | | | |_) |
|_| |_| |_|\___/|_| |_| |_|\___|_| |_|\__(_) .__/|_| |_| .__/
                                           |_|         |_|

Integrate

Latest Stable Version Total Downloads Monthly Downloads

Change log

Intro

What is moment.php?

Date library for parsing, manipulating and formatting dates w/ i18n.

Any dependencies?

PHP 5.3 or later since moment.php is based on php's DateTime Class.


Install

Easy install via composer. Still no idea what composer is? Inform yourself here.


Quick examples

Get a moment


Accepted date formats

Moment parses the following date formats as input:


Switch locale

Have a look at the folder to see all supported languages. Default locale is .

Supported languages so far:

Arabic (Tunisia) Catalan Czech Danish German (Germany) English (Canada) English (British) English (American) Esperanto Spanish (Europe) Farsi Finnish French (Canada) French (Europe) Hungarian Indonesian Italian Japanese Kazakh Latvian (Latviešu) Dutch Lengadocian Polish Portuguese (Brazil) Portuguese (Portugal) Russian (Basic version) Swedish Thai Turkish Ukrainian Vietnamese Chinese Chinese (traditional)


Switch timezones

Change default timezone


Custom format

I. PHP only (Standard)

Formats are based on PHP's Date function and DateTime class.

II. Non-php formats

You can now inject different format handling by passing along a class which implements the . You can find an example within the test folder for implementing all formats from moment.js. Thanks to Ashish for taking the time to match formats to those of PHP. Have a look at the test script to see the example in action.

Everybody can write format classes in the same manner. Its easy and scalable.

Custom formats can also come as part of every Locale. If it does not exist for your locale yet go ahead and add it. See an example for the French locale.

III. Easy text escaping

Just wrap all your text within and all characters will be automatically escaped for you.

IV. Fixed ordinal representations

PHP's interal ordinal calculation seems to be buggy. I added a quick fix to handle this issue.

The following example prints the week of the year of the given date. It should print :


Create custom moments and manipulate it

I. Past/Future moments

II. Clone a given moment

Sometimes its useful to take a given moment and work with it without changing the origin. For that use .

Alternately, you can enable immutable mode on the origin.

Immutable mode makes all modification methods call cloning() implicitly before applying their modifications.

III. Methods for manipulating the date/time

Add Subtract
addSeconds($s) subtractSeconds($s)
addMinutes($i) subtractMinutes($i)
addHours($h) subtractHours($h)
addDays($d) subtractDays($d)
addWeeks($w) subtractWeeks($w)
addMonths($m) subtractMonths($m)
addYears($y) subtractYears($y)

IV. Setter/Getter

Setter Getter
setSecond($s) getSecond()
setMinute($m) getMinute()
setHour($h) getHour()
setDay($d) getDay()
setMonth($m) getMonth()
setYear($y) getYear()
-- getQuarter()

Difference between dates


Get date periods (week, month, quarter)

Sometimes its helpful to get the period boundaries of a given date. For instance in case that today is Wednesday and I need the starting-/end dates from today's week. Allowed periods are , and .

Same procedure for monthly and quarterly periods:


Calendar Times

Calendar time displays time relative to , but slightly differently than . will format a date with different strings depending on how close to today the date is.

Time Display
Last week Last Monday at 15:54
The day before Yesterday at 15:54
The same day Today at 15:54
The next day Tomorrow at 15:54
The next week Wednesday at 15:54
Everything else 04/09/2014

Note: Use to leave out the time .


startOf / endOf

Same process as for moment.js: mutates the original moment by setting it to the start/end of a unit of time.

Note: I ignored the period of since we are not dealing with milliseconds.


Get dates for given weekdays for upcoming weeks

For one of my customers I needed to get moments by selected weekdays. The task was: give me the dates for and for the next three weeks. So I added a small handler which does exactly this. As result you will receive an array filled with .

You can now run through the result and put it formatted into a drop-down field or for whatever you might need it.


Roadmap


Change Log

Unreleased

1.33.0

1.32.1

1.32.0

1.31.0

1.30.1

1.30.0

1.29.0

1.28.3

1.28.2

1.28.1

1.28.0

1.27.0

1.26.10

1.26.9

1.26.8

1.26.7

1.26.6

1.26.5

1.26.4

1.26.3

1.26.2

1.26.1

1.26.0

1.25.1

1.25

1.24

1.23.1

1.23.0

1.22.0

1.21.0

1.20.9

1.20.8

1.20.7

1.20.6

1.20.5

1.20.4

1.20.3

1.20.2

1.20.1

1.20.0

1.19.0

1.18.0

1.17.0

1.16.0

1.15.0

1.14.1

1.14.0

1.13.0

1.12.0

1.11.4

1.11.3

1.11.1

1.11.0

1.10.4

1.10.3

1.10.2

1.10.1

1.10.0

1.9.1

1.9.0

1.8.1

1.8.0

1.7.2

1.7.1

1.7.0

1.6.0

1.5.3

1.5.2

1.5.1

1.5.0

1.4.0

1.3.0


Contributing

The maintainers of this project suggest following the contribution guide.

License

Moment.php is freely distributable under the terms of the MIT license.

Copyright (c) 2017 Tino Ehrich

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


All versions of moment with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
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 fightbulc/moment contains the following files

Loading the files please wait ....