mirror of
https://github.com/wiosna-dev/limesurvey-api-client.git
synced 2026-03-12 10:11:49 +01:00
Tests - use common method to create/prepare date
This commit is contained in:
38
tests/Utilities/DateUtility.php
Normal file
38
tests/Utilities/DateUtility.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* (c) Meritoo.pl, http://www.meritoo.pl
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Meritoo\LimeSurvey\Test\ApiClient\Utilities;
|
||||
|
||||
use DateTime;
|
||||
|
||||
/**
|
||||
* Date-related utility
|
||||
*
|
||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||
* @copyright Meritoo.pl
|
||||
*/
|
||||
class DateUtility
|
||||
{
|
||||
/**
|
||||
* Returns date formatted with long or medium format
|
||||
*
|
||||
* @param bool $useLongFormat (optional) If is set to true, long format will be used (default behaviour).
|
||||
* Otherwise - medium format.
|
||||
* @return string
|
||||
*/
|
||||
public static function getDateTime($useLongFormat = true)
|
||||
{
|
||||
$format = 'Y-m-d H:i';
|
||||
|
||||
if ($useLongFormat) {
|
||||
$format = 'Y-m-d H:i:s';
|
||||
}
|
||||
|
||||
return (new DateTime())->format($format);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user