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

Commit 3b7c221

Browse files
authored
Merge pull request #8439 from RakeshJesadiya/datetime-library
Add Datetime Library
2 parents 8b7c4f2 + b1b5361 commit 3b7c221

File tree

3 files changed

+66
-8
lines changed

3 files changed

+66
-8
lines changed

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -251,34 +251,39 @@ pages:
251251

252252
- label: Configuration
253253
children:
254-
- label: Sensitive Environment Settings
255-
url: /extension-dev-guide/configuration/sensitive-and-environment-settings.html
256254

257255
- label: Configuration Importers
258256
url: /extension-dev-guide/configuration/importers.html
259257

258+
- label: Sensitive Environment Settings
259+
url: /extension-dev-guide/configuration/sensitive-and-environment-settings.html
260+
260261
- label: Framework
261262
children:
262-
- label: Serialize Library
263-
url: /extension-dev-guide/framework/serializer.html
264263

265264
- label: Array Manager
266265
url: /extension-dev-guide/framework/array-manager.html
267266

267+
- label: DateTime Library
268+
url: /extension-dev-guide/framework/datetime.html
269+
270+
- label: Serialize Library
271+
url: /extension-dev-guide/framework/serializer.html
272+
268273
- label: URL Library
269274
url: /extension-dev-guide/framework/url-library.html
270275

271276
- label: Security
272277
children:
273278

274-
- label: XSS Prevention
275-
url: /extension-dev-guide/xss-protection.html
279+
- label: Content Security Policies
280+
url: /extension-dev-guide/security/content-security-policies.html
276281

277282
- label: Non-secure functions
278283
url: /extension-dev-guide/security/non-secure-functions.html
279284

280-
- label: Content Security Policies
281-
url: /extension-dev-guide/security/content-security-policies.html
285+
- label: XSS Prevention
286+
url: /extension-dev-guide/xss-protection.html
282287

283288
- label: Versioning
284289
url: /extension-dev-guide/versioning/
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
This DateTime library provides utilities to work with date and time formatting. Provided methods in this library are described below.
9+
10+
## Usage
11+
12+
|Method|Description|
13+
|--- |--- |
14+
| `formatDate` | Format the date to the Magento internal format |
15+
| `isEmptyDate` | Check whether provided date value is empty or null |
16+
17+
### Example
18+
19+
The following example shows how to format the current date and time into the Magento internal format.
20+
21+
```php
22+
<?php
23+
24+
use Magento\Framework\Stdlib\DateTime;
25+
26+
...
27+
/**
28+
* @var DateTime
29+
*/
30+
private $dateTime;
31+
32+
/**
33+
* SomeClass constructor.
34+
*
35+
* @param DateTime $dateTime
36+
*/
37+
public function __construct(DateTime $dateTime)
38+
{
39+
$this->dateTime = $dateTime;
40+
}
41+
42+
/**
43+
* display current date to internal format time zone
44+
*
45+
* @return string
46+
*/
47+
public function getFormatDate(): string
48+
{
49+
return $this->dataTime->formatDate(time());
50+
}
51+
52+
...
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)