This repository was archived by the owner on Nov 19, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +58
-0
lines changed
v2.3/extension-dev-guide/framework
v2.4/extension-dev-guide/framework Expand file tree Collapse file tree 3 files changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -265,6 +265,9 @@ pages:
265
265
- label : Array Manager
266
266
url : /extension-dev-guide/framework/array-manager.html
267
267
268
+ - label : DateTime Library
269
+ url : /extension-dev-guide/framework/datetime.html
270
+
268
271
- label : Security
269
272
children :
270
273
Original file line number Diff line number Diff line change
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
+ ...
Original file line number Diff line number Diff line change
1
+ ../../../v2.3/extension-dev-guide/framework/datetime.md
You can’t perform that action at this time.
0 commit comments