Here's a function that will do it for you accurately [by rounding, not cutting off]:
function getTimestamp[]
{
$microtime = floatval[substr[[string]microtime[], 1, 8]];
$rounded = round[$microtime, 3];
return date["Y-m-d H:i:s"] . substr[[string]$rounded, 1, strlen[$rounded]];
}
Explanation:
microtime[] returns 2 numbers as 1 string, delimited by a space. the 2nd number is the amount of seconds since the unix epoch, and the 1st number is the amount of microseconds since the 2nd number. Basically, the first number is the amount of microseconds expressed in a 8 precision format [0.00000000] and trailing 0s are never cut off.
We round this to a precision of 3 [0.00], and cut off the leading 0, and append that to the actual timestamp.
For some reason the php doc for u, microseconds, doesn't seem to be actually supported. I get 0.000 everytime when using that method. So I resorted to microtime[] as a backup solution.
108 votes
1 answers
I created a function and it returns a date looks like: 2016-07-15T10:10:52.031563+00:00
It's fine but the problem is digits for milliseconds. How to remove the 3 last digits? I only need 3 ones.
private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
2022-03-8
Write your answer
768
votes
Answer
Solution:
Theu
modifier will always return six digits. Quoting the manual:
Microseconds [added in PHP 5.2.2]. Note that date[] will always generate 000000 since it takes an integer parameter, whereas DateTime::format[] does support microseconds if DateTime was created with microseconds.
If you don't want that, you have to manually insert the format you need, e.g.
return $d->format['Y-m-d\Th:i:s.'] . substr[$micro, 0, 3] . $d->format['P'];
This will then output something like2016-07-15T12:29:30.546+02:00
Share solution ↓
Additional Information:
Date the issue was resolved:
2022-03-8
Link To Source
Link To Answer People are also looking for solutions of the problem:
403 this action is unauthorized.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Ngày --- --- d
ngày trong tháng, 2 chữ số với số 0 hàng đầu 01
đến 31
D
Một biểu diễn văn bản của một ngày, ba chữ cái Mon
đến ____10
private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
1 '] Một đại diện văn bản đầy đủ của ngày trong tuần private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
5 đến private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
6 private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
7 ISO 8601 Đại diện số của ngày trong tuần private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
2 [cho thứ Hai] đến private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
9 [cho Chủ nhật] return $d->format['Y-m-d\Th:i:s.'] . substr[$micro, 0, 3] . $d->format['P'];
1, return $d->format['Y-m-d\Th:i:s.'] . substr[$micro, 0, 3] . $d->format['P'];
2, return $d->format['Y-m-d\Th:i:s.'] . substr[$micro, 0, 3] . $d->format['P'];
3 hoặc return $d->format['Y-m-d\Th:i:s.'] . substr[$micro, 0, 3] . $d->format['P'];
4. Hoạt động tốt với private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
1 return $d->format['Y-m-d\Th:i:s.'] . substr[$micro, 0, 3] . $d->format['P'];
6 Đại diện số của ngày trong tuần return $d->format['Y-m-d\Th:i:s.'] . substr[$micro, 0, 3] . $d->format['P'];
7 [cho Chủ nhật] đến return $d->format['Y-m-d\Th:i:s.'] . substr[$micro, 0, 3] . $d->format['P'];
8 [cho thứ bảy] return $d->format['Y-m-d\Th:i:s.'] . substr[$micro, 0, 3] . $d->format['P'];
9 ngày trong năm [bắt đầu từ 0] return $d->format['Y-m-d\Th:i:s.'] . substr[$micro, 0, 3] . $d->format['P'];
7 đến u
1 tuần của năm, các tuần bắt đầu vào ví dụ Thứ Hai: u
3 [Tuần thứ 42 trong năm] tháng --- --- u
4 một đại diện văn bản đầy đủ của một tháng, chẳng hạn như tháng 1 hoặc tháng 3 Các số không hàng đầu 01
đến u
9 2016-07-15T12:29:30.546+02:00
0 Một biểu diễn văn bản ngắn trong một tháng, ba chữ cái 2016-07-15T12:29:30.546+02:00
1 đến 2016-07-15T12:29:30.546+02:00
2 2016-07-15T12:29:30.546+02:00
3 Biểu diễn số của một tháng, mà không có số 0 hàng đầu private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
2 đến. 2016-07-15T12:29:30.546+02:00
9 Cho dù đó là một năm bước nhảy private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
2 nếu đó là một năm bước nhảy, return $d->format['Y-m-d\Th:i:s.'] . substr[$micro, 0, 3] . $d->format['P'];
7 khác. d
2 ISO 8601 Năm đánh số tuần. Điều này có cùng giá trị với d
3, ngoại trừ nếu số tuần ISO [u
2] thuộc về năm trước hoặc năm sau, năm đó được sử dụng thay thế. Ví dụ: d
5 hoặc d
6 d
7 Một đại diện số đầy đủ được mở rộng là một năm, ít nhất 4 chữ số, với d
8 trong nhiều năm BCE và d
9 trong nhiều năm CE. Ví dụ: 01
0, 01
1, 01
2, 01
3 01
4 Một biểu diễn số đầy đủ được mở rộng nếu được tái hiện hoặc biểu diễn số đầy đủ tiêu chuẩn nếu có thể [như d
3]. Ít nhất bốn chữ số. Năm BCE được tiền tố với d
8. Nhiều năm xa hơn [và bao gồm] 01
7 được đặt trước một d
9. Ví dụ: 01
0, 31
0, d
5, 01
3 d
3 Một đại diện số đầy đủ của một năm, ít nhất 4 chữ số, với d
8 trong năm BCE. Ví dụ: 01
0, 31
0, d
5, d
6, 31
9 D
0 Một biểu diễn hai chữ số của một năm Ví dụ: D
1 hoặc D
2 D
8 D
9 Thời gian internet swatch Mon
0 đến Mon
1 Mon
2 Định dạng 12 giờ của một giờ mà không dẫn đầu số 0 private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
2 đến u
9 Mon
5 Định dạng 24 giờ trong giờ private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
01 Định dạng 24 giờ của một giờ với số 0 hàng đầu private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
02 đến Mon
7 private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
04 phút với các số không hàng đầu private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
02 đến private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
06 private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
07 giây với số 0 hàng đầu private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
02 đến private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
06 u
microseconds. Lưu ý rằng ngày [] sẽ luôn tạo private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
11 vì nó có tham số INT, trong khi Dateas :: Pormat [] không hỗ trợ micro giây nếu DateTime được tạo bằng micro giây. Ví dụ: private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
12 private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
13 mili giây. Tương tự như vậy áp dụng như đối với u
. Ví dụ: private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
15 Timezone --- --- private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
16 Số nhận dạng Timezone Ví dụ: private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
17, private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
18, private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
19 private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
20 [vốn I] Có hay không ngày có tiết kiệm ánh sáng ban ngày private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
2 nếu thời gian tiết kiệm ánh sáng ban ngày, return $d->format['Y-m-d\Th:i:s.'] . substr[$micro, 0, 3] . $d->format['P'];
7. private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
23 Sự khác biệt đối với thời gian Greenwich [GMT] mà không có đại tràng giữa giờ và phút Ví dụ: private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
24 private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
25 khác biệt với thời gian Greenwich [GMT] với đại tràng giữa giờ và phút ví dụ: private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
26 private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
27 giống như private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
25 Php 8.0.0] Ví dụ: private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
29 hoặc private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
26 private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
33 Chữ viết tắt thời gian, nếu được biết; nếu không thì độ lệch GMT. Ví dụ: private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
34, private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
35, private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
36 private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
29 offset múi giờ trong giây. Sự bù đắp cho múi giờ ở phía tây UTC luôn âm và đối với những người ở phía đông UTC luôn tích cực. private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
38 đến private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
39 Ngày/giờ đầy đủ --- --- private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
40 ISO 8601 Ngày 2004-02-12T15: 19: 21+00: 00 Epoch Unix [ngày 1 tháng 1 năm 1970 00:00:00 GMT] Xem thêm Time []date[] will always generate private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
11 since it takes an int parameter, whereas DateTime::format[] does support microseconds if DateTime was created with microseconds.
Example: private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
12
private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
13
Milliseconds. Same note applies as for u
.
Example: private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
15
Timezone
---
---
private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
16
Timezone identifier
Examples: private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
17, private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
18, private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
19
private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
20 [capital i]
Whether or not the date is in daylight saving time
private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
2 if Daylight Saving Time, return $d->format['Y-m-d\Th:i:s.'] . substr[$micro, 0, 3] . $d->format['P'];
7 otherwise.
private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
23
Difference to Greenwich time [GMT] without colon between hours and minutes
Example: private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
24
private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
25
Difference to Greenwich time [GMT] with colon between hours and minutes
Example: private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
26
private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
27
The same as private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
25, but returns private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
29 instead of private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
30 [available as of PHP 8.0.0]
Examples: private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
29 or private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
26
private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
33
Timezone abbreviation, if known; otherwise the GMT offset.
Examples: private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
34, private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
35, private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
36
private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
29
Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive.
private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
38 through private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
39
Full Date/Time
---
---
private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
40
ISO 8601 date
2004-02-12T15:19:21+00:00
private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
41
» RFC 2822/» RFC 5322 formatted date
Example: private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
42
private function getFormattedDate[$time = 'now']{
$t = microtime[true];
$micro = sprintf["%06d",[$t - floor[$t]] * 1000000];
$d = new DateTime[ date['Y-m-d H:i:s.'.$micro, $t] ];
$d->modify[$time];
return $d->format['Y-m-d\Th:i:s.uP']; // note at point on "u"
}
43
Seconds since the Unix Epoch [January 1 1970 00:00:00 GMT]
See also time[]