8000 Merge branch '5.4' into 6.3 · symfony/symfony-docs@5819a4a · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5819a4a

Browse files
committed
Merge branch '5.4' into 6.3
* 5.4: Update formatterhelper.rst
2 parents 63b6901 + 62ff824 commit 5819a4a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

components/console/helpers/formatterhelper.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,28 @@ If you don't want to use suffix at all, pass an empty string::
119119
$truncatedMessage = $formatter->truncate('test', 10);
120120
// result: test
121121
// because length of the "test..." string is shorter than 10
122+
123+
Formatting Time
124+
---------------
125+
126+
Sometimes you want to format seconds to time. This is possible with the
127+
:method:`Symfony\\Component\\Console\\Helper\\Helper::formatTime` method.
128+
The first argument is the seconds to format and the second argument is the
129+
precision (default ``1``) of the result::
130+
131+
Helper::formatTime(42); // 42 secs
132+
Helper::formatTime(125); // 2 mins
133+
Helper::formatTime(125, 2); // 2 mins, 5 secs
134+
Helper::formatTime(172799, 4); // 1 day, 23 hrs, 59 mins, 59 secs
135+
136+
Formatting Memory
137+
-----------------
138+
139+
Sometimes you want to format memory to GiB, MiB, KiB and B. This is possible with the
140+
:method:`Symfony\\Component\\Console\\Helper\\Helper::formatMemory` method.
141+
The only argument is the memory size to format::
142+
143+
Helper::formatMemory(512); // 512 B
144+
Helper::formatMemory(1024); // 1 KiB
145+
Helper::formatMemory(1024 * 1024); // 1.0 MiB
146+
Helper::formatMemory(1024 * 1024 * 1024); // 1 GiB

0 commit comments

Comments
 (0)
0