https://github.com/chinleung/php-weekday
Easily get name of weekday and value from name between different languages.
https://github.com/chinleung/php-weekday
localization php translation weekday
Last synced: 5 months ago
JSON representation
Easily get name of weekday and value from name between different languages.
- Host: GitHub
- URL: https://github.com/chinleung/php-weekday
- Owner: chinleung
- License: mit
- Created: 2019-07-31T18:25:28.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-04-27T18:29:25.000Z (about 6 years ago)
- Last Synced: 2025-02-13T22:38:06.529Z (over 1 year ago)
- Topics: localization, php, translation, weekday
- Language: PHP
- Size: 87.9 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# PHP Weekday
[](https://packagist.org/packages/chinleung/php-weekday)
[](https://travis-ci.org/chinleung/php-weekday)
[](https://scrutinizer-ci.com/g/chinleung/php-weekday)
[](https://packagist.org/packages/chinleung/php-weekday)
Easily get name of weekday and value from name between different languages.
## Installation
You can install the package via composer:
```bash
composer require chinleung/php-weekday
```
## Usage
### Retrieve a name from a value
``` php
Weekday::getNameFromValue(0, 'en'); // Sunday
(new Weekday(0, 'en'))->getName(); // Sunday
```
### Retrieving a name from a value for a different locale
``` php
Weekday::getNameFromValue(0, 'fr'); // Dimanche
(new Weekday(0, 'en'))->getName('fr'); // Dimanche
```
### Retrieving a value from the name
``` php
Weekday::getValueFromName('Sunday', 'en'); // 0
Weekday::getValueFromName('Lundi', 'fr'); // 1
(new Weekday('wednesday', 'en'))->getName(); // 3
```
### Retrieving all names for a locale
``` php
Weekday::getNames('en'); // ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
```
### Changing the locale of an instance
``` php
(new Weekday(1, 'en'))->setLocale('fr')->getName(); // Lundi
```
### Testing
``` bash
composer test
```
### Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
### Security
If you discover any security related issues, please email hello@chinleung.com instead of using the issue tracker.
## Credits
- [Chin Leung](https://github.com/chinleung)
- [All Contributors](../../contributors)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
## PHP Package Boilerplate
This package was generated using the [PHP Package Boilerplate](https://laravelpackageboilerplate.com).