Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit de29fd6

Browse files
author
RakeshJesadiya
committed
datetime-library
1 parent 00f5d7a commit de29fd6

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

src/_data/toc/php-developer-guide.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,9 @@ pages:
265265
- label: Array Manager
266266
url: /extension-dev-guide/framework/array-manager.html
267267

268+
- label: DateTime Library
269+
url: /extension-dev-guide/framework/datetime.html
270+
268271
- label: Security
269272
children:
270273

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
group: php-developer-guide
3+
title: DateTime Library
4+
contributor_name: Rakesh Jesadiya
5+
contributor_link: https://github.com/RakeshJesadiya
6+
---
7+
8+
## Overview
9+
10+
This DateTime library provides utilities to work with formatting of date time. Provided methods in this library are described below.
11+
12+
## Usage
13+
14+
|Method|Description|
15+
|--- |--- |
16+
| `formatDate` | Format date to internal format |
17+
| `isEmptyDate` | Check whether sql date is empty |
18+
19+
### Example
20+
21+
The following example shows how to Format current date and time to internal format.
22+
23+
```php
24+
<?php
25+
26+
use Magento\Framework\Stdlib\DateTime;
27+
28+
...
29+
/**
30+
* @var DateTime
31+
*/
32+
private $dateTime;
33+
34+
/**
35+
* SomeClass constructor.
36+
*
37+
* @param DateTime $dateTime
38+
*/
39+
public function __construct(DateTime $dateTime)
40+
{
41+
$this->dateTime = $dateTime;
42+
}
43+
44+
/**
45+
* display current date to internal format time zone
46+
*
47+
* @return string
48+
*/
49+
public function getFormatDate(): string
50+
{
51+
return $this->dataTime->formatDate(time());
52+
}
53+
54+
...
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../v2.3/extension-dev-guide/framework/datetime.md

0 commit comments

Comments
 (0)