| 1 |
<?php |
| 2 |
/** |
| 3 |
* Phone Number Faker Class |
| 4 |
* |
| 5 |
* @package Timetics |
| 6 |
*/ |
| 7 |
namespace Timetics\Core\DummyData\Provider; |
| 8 |
|
| 9 |
/** |
| 10 |
* Date time faker class |
| 11 |
*/ |
| 12 |
class DateTime { |
| 13 |
/** |
| 14 |
* Get genrated date |
| 15 |
* |
| 16 |
* @return string |
| 17 |
*/ |
| 18 |
public static function date( $format = 'Y-m-d' ) { |
| 19 |
return date( $format, self::timestamp() ); |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* Get generated time |
| 24 |
* |
| 25 |
* @return string |
| 26 |
*/ |
| 27 |
public static function time( $format = 'h:i a' ) { |
| 28 |
return date( $format, self::timestamp() ); |
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* Get generated timestamp |
| 33 |
* |
| 34 |
* @return string |
| 35 |
*/ |
| 36 |
private static function timestamp() { |
| 37 |
$start_timestamp = strtotime( '1970-01-01' ); |
| 38 |
$end_timestamp = strtotime( '2030-12-31' ); |
| 39 |
|
| 40 |
// Generate a random timestamp within the valid range |
| 41 |
$random_timestamp = mt_rand( $start_timestamp, $end_timestamp ); |
| 42 |
|
| 43 |
// Format the timestamp into a valid date format |
| 44 |
return $random_timestamp; |
| 45 |
} |
| 46 |
} |
| 47 |
|