add instance method for access static
This commit is contained in:
1 parent
0b84f1a824
commit
55ba79a83f
2 files changed
+11
-6
No files matched your search
@@ -5,7 +5,7 @@ hekmatinasser/verta
|
|||||||
|
|
||||||
- Verta is a jalali calendar that was used in persian datetime
|
- Verta is a jalali calendar that was used in persian datetime
|
||||||
|
|
||||||
- Calendar conversion is based on the [algorithm provided by Morteza Parvini, Vahid Sohrablou, Roozbeh Pournader and Mohammad Tou'si](http://IranPHP.org).
|
- Calendar conversion is based on the algorithm provided by Morteza Parvini, Vahid Sohrablou, Roozbeh Pournader and Mohammad Tou'si.
|
||||||
|
|
||||||
Run the Composer update comand
|
Run the Composer update comand
|
||||||
|
|
||||||
@@ -34,7 +34,8 @@ In your `config/app.php` add `'Hekmatinasser\Verta\VertaServiceProvider::class'`
|
|||||||
## Basic Usage
|
## Basic Usage
|
||||||
|
|
||||||
### Verta
|
### Verta
|
||||||
You can use verta `use \Verta as Verta ;`
|
You can use verta
|
||||||
|
`use \Verta as Verta ;`
|
||||||
#### `$dt = new Verta();`
|
#### `$dt = new Verta();`
|
||||||
``` php
|
``` php
|
||||||
// default timestamp is now
|
// default timestamp is now
|
||||||
@@ -42,7 +43,8 @@ $dt = new Verta();
|
|||||||
|
|
||||||
// pass timestamps
|
// pass timestamps
|
||||||
$dt = new Verta(1333857600);
|
$dt = new Verta(1333857600);
|
||||||
// OR
|
|
||||||
|
// pass string datetime
|
||||||
$dt = new Verta('2016-12-27 14:12:32');
|
$dt = new Verta('2016-12-27 14:12:32');
|
||||||
|
|
||||||
//pass datetime object
|
//pass datetime object
|
||||||
@@ -50,9 +52,12 @@ $dt = new \Datetime();
|
|||||||
return new Verta($dt); // 1395-12-09 15:05:56
|
return new Verta($dt); // 1395-12-09 15:05:56
|
||||||
|
|
||||||
// pass carbon object
|
// pass carbon object
|
||||||
$c = Carbon::now();
|
$c = \Carbon::now();
|
||||||
return new Verta($c); // 1395-12-09 15:05:56
|
return new Verta($c); // 1395-12-09 15:05:56
|
||||||
|
|
||||||
|
// access static
|
||||||
|
return Verta::instance('2016-12-25 11:12:36'); //1395-10-05 11:12:36
|
||||||
|
|
||||||
// pass strings persian date
|
// pass strings persian date
|
||||||
$dt = Verta::parse('1395-10-07 14:12:32');
|
$dt = Verta::parse('1395-10-07 14:12:32');
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -288,8 +288,8 @@ class Verta extends DateTime {
|
|||||||
*
|
*
|
||||||
* @return static
|
* @return static
|
||||||
*/
|
*/
|
||||||
public static function instance(DateTime $datetime) {
|
public static function instance($datetime = null, $timezone = null) {
|
||||||
return new static($datetime, $datetime->getTimeZone());
|
return new static($datetime, $timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user