Hướng dẫn php dateinterval format - định dạng ngày tháng trong php

❮ Tham khảo ngày/giờ PHP

Thí dụ

Tính khoảng thời gian giữa hai ngày, sau đó định dạng khoảng thời gian:

$date1=date_create("2013-01-01");
$date2=date_create("2013-02-10");
$diff=date_diff($date1,$date2);

// %A đầu ra Tổng số ngày của Daysecho $ Diff-> ("Tổng số ngày: %a.");?>
echo $diff->format("Total number of days: %a.");
?>

Hãy tự mình thử »


Định nghĩa và cách sử dụng

Hàm date_interval_format () là bí danh của dateInterval :: định dạng ().

Hàm dateInterVal :: định dạng () được sử dụng để định dạng khoảng. & Nbsp;


Cú pháp

DateInterval :: Định dạng (Định dạng)

Giá trị tham số

Tham sốSự mô tả
định dạngYêu cầu. Chỉ định định dạng. Các ký tự sau có thể được sử dụng trong chuỗi tham số định dạng:
  • % - % theo nghĩa đen
  • Y - năm, ít nhất 2 chữ số với số 0 hàng đầu (ví dụ 03)
  • y - năm (ví dụ 3)
  • M - Tháng, với số 0 hàng đầu (ví dụ 06)
  • M - Tháng (ví dụ 6)
  • D - Ngày, với số 0 hàng đầu (ví dụ 09)
  • D - Ngày (ví dụ 9)
  • A - Tổng số ngày là kết quả của Date_Diff ()
  • H - Giờ, với số 0 hàng đầu (ví dụ: 08, 23)
  • H - giờ (ví dụ 8, 23)
  • I - phút, với số 0 hàng đầu (ví dụ: 08, 23)
  • i - phút (ví dụ 8, 23)
  • S - giây, với số 0 hàng đầu (ví dụ: 08, 23)
  • S - giây (ví dụ 8, 23)
  • F - micro giây, ít nhất 6 chữ số (ví dụ 004403, 235689)
  • F - micro giây (ví dụ 4403, 235689)
  • R - ký " -" khi âm "+" khi dương
  • R - ký " -" khi âm, trống khi dương

Lưu ý: Mỗi ký tự định dạng phải được đặt trước bằng một dấu hiệu %! Each format character must be prefixed by a % sign!



Chi tiết kỹ thuật

Giá trị trở lại:Trả về khoảng thời gian định dạng
Phiên bản PHP:5.3+
PHP Changelog:Php 7.1: Đã thêm các tham số F và F

❮ Tham khảo ngày/giờ PHP

Tôi đang sử dụng mã này:

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$months = $due_date->diff($today);

$months->format("%m");

$fine = 0.02 * $price * $months; // i got error in this line

$bill = $price + $fine;

Tôi muốn tính toán, nếu ai đó bị trễ trả thì họ sẽ bị phạt mỗi tháng. Và thông báo lỗi là:

Object of class DateInterval could not be converted to int

Đã hỏi ngày 25 tháng 6 năm 2016 lúc 13:44Jun 25, 2016 at 13:44

2

Thông báo lỗi xuất hiện vì

Object of class DateInterval could not be converted to int
0 không phải là INT, mà là một đối tượng DateTime như thế này:

DateInterval Object
(
    [y] => 0
    [m] => 4
    [d] => 12
    [h] => 6
    [i] => 56
    [s] => 9
    [weekday] => 0
    [weekday_behavior] => 0
    [first_last_day_of] => 0
    [invert] => 0
    [days] => 133
    [special_type] => 0
    [special_amount] => 0
    [have_weekday_relative] => 0
    [have_special_relative] => 0
)

Bạn có thể nhận được giá trị số nguyên của những tháng như thế này

$due_date = new DateTime('13-02-2016');

$today = new DateTime();
$months = $due_date->diff($today);

echo $months->m;

Kiểm tra kết quả trên trong hộp cát PHP

Vì vậy, về cơ bản mã của bạn sẽ trông giống như

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$months = $due_date->diff($today);

$fine = 0.02 * $price * $months->m; // i got no error in this line

$bill = $price + $fine;

Đã trả lời ngày 25 tháng 6 năm 2016 lúc 13:51Jun 25, 2016 at 13:51

1

Bạn tính toán sự khác biệt trong tháng, nhưng bạn không bao giờ thực sự sử dụng giá trị đó. Phương thức

Object of class DateInterval could not be converted to int
1 đưa ra một cái gì đó, nhưng không thay đổi ngày thực tế.

Hãy thử nó như thế này:

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$diff = $due_date->diff($today);

$months = $diff->format("%m");

$fine = 0.02 * $price * $months;

$bill = $price + $fine;

Đã trả lời ngày 25 tháng 6 năm 2016 lúc 13:48Jun 25, 2016 at 13:48

PevarapevaraPevara

14.1k1 Huy hiệu vàng32 Huy hiệu bạc47 Huy hiệu đồng1 gold badge32 silver badges47 bronze badges

3

Câu trả lời của Peter Darmis là sai. Tôi không thể xuống cũng như bình luận vì vậy tôi sẽ thêm câu trả lời mới này.

DateInterval đại diện cho một khoảng thời gian bằng cách giải mã khoảng thời gian ở các phần khác nhau, năm, tháng, ngày, v.v ... vì vậy "M" trong giải pháp được đề xuất sẽ không bao giờ lớn hơn 12.

Vì vậy, có lẽ bạn nên làm điều gì đó như thế này:

$due_date = new DateTime('13-02-2016');

$today = new DateTime();
$diff = $due_date->diff($today);

$months = ($diff->y * 12) + $diff->m;

echo $months;

Kiểm tra nó trong hộp cát: http://sandbox.onlinephpfunces.com/code/907b39ffee4586c4c9481ff3e0ea1aeb2d27c7b8

Đã trả lời ngày 13 tháng 9 năm 2019 lúc 14:35Sep 13, 2019 at 14:35

Iblancoblancoiblanco

411 Huy hiệu bạc6 Huy hiệu đồng1 silver badge6 bronze badges

(Php 5> = 5.3.0, Php 7, Php 8)

DateInterval :: __ Xây dựng - Tạo một đối tượng DateInterval mớiCreates a new DateInterval object

Sự mô tả

định dạng DateInterval::__construct(string

Object of class DateInterval could not be converted to int
2)

Yêu cầu. Chỉ định định dạng. Các ký tự sau có thể được sử dụng trong chuỗi tham số định dạng:

% - % theo nghĩa đen

Y - năm, ít nhất 2 chữ số với số 0 hàng đầu (ví dụ 03)

y - năm (ví dụ 3)

M - Tháng, với số 0 hàng đầu (ví dụ 06)
M - Tháng (ví dụ 6)Sự mô tả
định dạngYêu cầu. Chỉ định định dạng. Các ký tự sau có thể được sử dụng trong chuỗi tham số định dạng:
% - % theo nghĩa đenY - năm, ít nhất 2 chữ số với số 0 hàng đầu (ví dụ 03)
y - năm (ví dụ 3)M - Tháng, với số 0 hàng đầu (ví dụ 06)
M - Tháng (ví dụ 6)D - Ngày, với số 0 hàng đầu (ví dụ 09)
D - Ngày (ví dụ 9)A - Tổng số ngày là kết quả của Date_Diff ()
% - % theo nghĩa đenY - năm, ít nhất 2 chữ số với số 0 hàng đầu (ví dụ 03)
y - năm (ví dụ 3)M - Tháng, với số 0 hàng đầu (ví dụ 06)

M - Tháng (ví dụ 6)

D - Ngày, với số 0 hàng đầu (ví dụ 09):

D - Ngày (ví dụ 9)

A - Tổng số ngày là kết quả của Date_Diff ()

H - Giờ, với số 0 hàng đầu (ví dụ: 08, 23)

Errors/Exceptions

H - giờ (ví dụ 8, 23)Exception when the

Object of class DateInterval could not be converted to int
3 cannot be parsed as an interval.

I - phút, với số 0 hàng đầu (ví dụ: 08, 23)

i - phút (ví dụ 8, 23)Sự mô tả
8.2.0 định dạng
8.0.0 Yêu cầu. Chỉ định định dạng. Các ký tự sau có thể được sử dụng trong chuỗi tham số định dạng:

% - % theo nghĩa đen

Y - năm, ít nhất 2 chữ số với số 0 hàng đầu (ví dụ 03)DateInterval objects

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$months = $due_date->diff($today);

$fine = 0.02 * $price * $months->m; // i got no error in this line

$bill = $price + $fine;
0

y - năm (ví dụ 3)

M - Tháng, với số 0 hàng đầu (ví dụ 06)DateInterval example

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$months = $due_date->diff($today);

$fine = 0.02 * $price * $months->m; // i got no error in this line

$bill = $price + $fine;
1

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$months = $due_date->diff($today);

$fine = 0.02 * $price * $months->m; // i got no error in this line

$bill = $price + $fine;
2

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$months = $due_date->diff($today);

$fine = 0.02 * $price * $months->m; // i got no error in this line

$bill = $price + $fine;
3

Đầu ra của ví dụ trên trong Php 8.2:

object(DateInterval)#1 (10) {
  ["y"]=>
  int(0)
  ["m"]=>
  int(0)
  ["d"]=>
  int(9)
  ["h"]=>
  int(0)
  ["i"]=>
  int(0)
  ["s"]=>
  int(0)
  ["f"]=>
  float(0)
  ["invert"]=>
  int(0)
  ["days"]=>
  bool(false)
  ["from_string"]=>
  bool(false)
}

Đầu ra của ví dụ trên trong Php 8:

object(DateInterval)#1 (16) {
  ["y"]=>
  int(0)
  ["m"]=>
  int(0)
  ["d"]=>
  int(9)
  ["h"]=>
  int(0)
  ["i"]=>
  int(0)
  ["s"]=>
  int(0)
  ["f"]=>
  float(0)
  ["weekday"]=>
  int(0)
  ["weekday_behavior"]=>
  int(0)
  ["first_last_day_of"]=>
  int(0)
  ["invert"]=>
  int(0)
  ["days"]=>
  bool(false)
  ["special_type"]=>
  int(0)
  ["special_amount"]=>
  int(0)
  ["have_weekday_relative"]=>
  int(0)
  ["have_special_relative"]=>
  int(0)
}

Đầu ra của ví dụ trên trong Php 7:

object(DateInterval)#1 (16) {
  ["y"]=>
  int(0)
  ["m"]=>
  int(0)
  ["d"]=>
  int(2)
  ["h"]=>
  int(0)
  ["i"]=>
  int(0)
  ["s"]=>
  int(0)
  ["f"]=>
  float(0)
  ["weekday"]=>
  int(0)
  ["weekday_behavior"]=>
  int(0)
  ["first_last_day_of"]=>
  int(0)
  ["invert"]=>
  int(0)
  ["days"]=>
  bool(false)
  ["special_type"]=>
  int(0)
  ["special_amount"]=>
  int(0)
  ["have_weekday_relative"]=>
  int(0)
  ["have_special_relative"]=>
  int(0)
}

Xem thêm

  • DateInterval :: định dạng () - định dạng khoảng thời gian
  • DateTime :: add () - Sửa đổi một đối tượng DateTime, với số lượng ngày, tháng, năm, giờ, phút và giây
  • DateTime :: sub () - trừ một số ngày, tháng, năm, giờ, phút và giây từ một đối tượng DateTime
  • DateTime :: Diff () - Trả về sự khác biệt giữa hai đối tượng DateTime

Owen tại niềm tin.com

9 năm trước

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$months = $due_date->diff($today);

$fine = 0.02 * $price * $months->m; // i got no error in this line

$bill = $price + $fine;
4

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$months = $due_date->diff($today);

$fine = 0.02 * $price * $months->m; // i got no error in this line

$bill = $price + $fine;
5

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$months = $due_date->diff($today);

$fine = 0.02 * $price * $months->m; // i got no error in this line

$bill = $price + $fine;
6

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$months = $due_date->diff($today);

$fine = 0.02 * $price * $months->m; // i got no error in this line

$bill = $price + $fine;
7

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$months = $due_date->diff($today);

$fine = 0.02 * $price * $months->m; // i got no error in this line

$bill = $price + $fine;
8

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$months = $due_date->diff($today);

$fine = 0.02 * $price * $months->m; // i got no error in this line

$bill = $price + $fine;
9

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$diff = $due_date->diff($today);

$months = $diff->format("%m");

$fine = 0.02 * $price * $months;

$bill = $price + $fine;
0

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$diff = $due_date->diff($today);

$months = $diff->format("%m");

$fine = 0.02 * $price * $months;

$bill = $price + $fine;
1

Buvinghausen tại Gmail Dot Com ¶

10 năm trước

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$diff = $due_date->diff($today);

$months = $diff->format("%m");

$fine = 0.02 * $price * $months;

$bill = $price + $fine;
2

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$diff = $due_date->diff($today);

$months = $diff->format("%m");

$fine = 0.02 * $price * $months;

$bill = $price + $fine;
3

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$diff = $due_date->diff($today);

$months = $diff->format("%m");

$fine = 0.02 * $price * $months;

$bill = $price + $fine;
1

Hernanibus ¶

4 năm trước

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$diff = $due_date->diff($today);

$months = $diff->format("%m");

$fine = 0.02 * $price * $months;

$bill = $price + $fine;
5

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$diff = $due_date->diff($today);

$months = $diff->format("%m");

$fine = 0.02 * $price * $months;

$bill = $price + $fine;
6

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$diff = $due_date->diff($today);

$months = $diff->format("%m");

$fine = 0.02 * $price * $months;

$bill = $price + $fine;
7

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$diff = $due_date->diff($today);

$months = $diff->format("%m");

$fine = 0.02 * $price * $months;

$bill = $price + $fine;
8

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$diff = $due_date->diff($today);

$months = $diff->format("%m");

$fine = 0.02 * $price * $months;

$bill = $price + $fine;
9

$due_date = new DateTime('13-02-2016');

$today = new DateTime();
$diff = $due_date->diff($today);

$months = ($diff->y * 12) + $diff->m;

echo $months;
0

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$diff = $due_date->diff($today);

$months = $diff->format("%m");

$fine = 0.02 * $price * $months;

$bill = $price + $fine;
1

Kevinpeno tại Gmail Dot Com ¶

11 năm trước

$due_date = new DateTime('13-02-2016');

$today = new DateTime();
$diff = $due_date->diff($today);

$months = ($diff->y * 12) + $diff->m;

echo $months;
2

$due_date = new DateTime('13-02-2016');

$today = new DateTime();
$diff = $due_date->diff($today);

$months = ($diff->y * 12) + $diff->m;

echo $months;
3

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$diff = $due_date->diff($today);

$months = $diff->format("%m");

$fine = 0.02 * $price * $months;

$bill = $price + $fine;
1

Daniellehr tại gmx dot de ¶

10 năm trước

$due_date = new DateTime('13-02-2016');

$today = new DateTime();
$diff = $due_date->diff($today);

$months = ($diff->y * 12) + $diff->m;

echo $months;
5

$due_date = new DateTime('13-02-2016');

$today = new DateTime();
$diff = $due_date->diff($today);

$months = ($diff->y * 12) + $diff->m;

echo $months;
6

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$diff = $due_date->diff($today);

$months = $diff->format("%m");

$fine = 0.02 * $price * $months;

$bill = $price + $fine;
1

Hernanibus ¶

11 năm trước

$due_date = new DateTime('13-02-2016');

$today = new DateTime();
$diff = $due_date->diff($today);

$months = ($diff->y * 12) + $diff->m;

echo $months;
8

$due_date = new DateTime('13-02-2016');

$today = new DateTime();
$diff = $due_date->diff($today);

$months = ($diff->y * 12) + $diff->m;

echo $months;
9

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$diff = $due_date->diff($today);

$months = $diff->format("%m");

$fine = 0.02 * $price * $months;

$bill = $price + $fine;
1

$due_date = new DateTime('13-02-2016');

$today = new DateTime();
$diff = $due_date->diff($today);

$months = ($diff->y * 12) + $diff->m;

echo $months;
3

10 năm trước

object(DateInterval)#1 (10) {
  ["y"]=>
  int(0)
  ["m"]=>
  int(0)
  ["d"]=>
  int(9)
  ["h"]=>
  int(0)
  ["i"]=>
  int(0)
  ["s"]=>
  int(0)
  ["f"]=>
  float(0)
  ["invert"]=>
  int(0)
  ["days"]=>
  bool(false)
  ["from_string"]=>
  bool(false)
}
1

object(DateInterval)#1 (10) {
  ["y"]=>
  int(0)
  ["m"]=>
  int(0)
  ["d"]=>
  int(9)
  ["h"]=>
  int(0)
  ["i"]=>
  int(0)
  ["s"]=>
  int(0)
  ["f"]=>
  float(0)
  ["invert"]=>
  int(0)
  ["days"]=>
  bool(false)
  ["from_string"]=>
  bool(false)
}
2

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$diff = $due_date->diff($today);

$months = $diff->format("%m");

$fine = 0.02 * $price * $months;

$bill = $price + $fine;
1

Hernanibus ¶

4 năm trước

object(DateInterval)#1 (10) {
  ["y"]=>
  int(0)
  ["m"]=>
  int(0)
  ["d"]=>
  int(9)
  ["h"]=>
  int(0)
  ["i"]=>
  int(0)
  ["s"]=>
  int(0)
  ["f"]=>
  float(0)
  ["invert"]=>
  int(0)
  ["days"]=>
  bool(false)
  ["from_string"]=>
  bool(false)
}
4

object(DateInterval)#1 (10) {
  ["y"]=>
  int(0)
  ["m"]=>
  int(0)
  ["d"]=>
  int(9)
  ["h"]=>
  int(0)
  ["i"]=>
  int(0)
  ["s"]=>
  int(0)
  ["f"]=>
  float(0)
  ["invert"]=>
  int(0)
  ["days"]=>
  bool(false)
  ["from_string"]=>
  bool(false)
}
5

object(DateInterval)#1 (10) {
  ["y"]=>
  int(0)
  ["m"]=>
  int(0)
  ["d"]=>
  int(9)
  ["h"]=>
  int(0)
  ["i"]=>
  int(0)
  ["s"]=>
  int(0)
  ["f"]=>
  float(0)
  ["invert"]=>
  int(0)
  ["days"]=>
  bool(false)
  ["from_string"]=>
  bool(false)
}
6

Kevinpeno tại Gmail Dot Com ¶

11 năm trước

$due_date = new DateTime('13-02-2016');

$today = new DateTime();
$diff = $due_date->diff($today);

$months = ($diff->y * 12) + $diff->m;

echo $months;
3

object(DateInterval)#1 (10) {
  ["y"]=>
  int(0)
  ["m"]=>
  int(0)
  ["d"]=>
  int(9)
  ["h"]=>
  int(0)
  ["i"]=>
  int(0)
  ["s"]=>
  int(0)
  ["f"]=>
  float(0)
  ["invert"]=>
  int(0)
  ["days"]=>
  bool(false)
  ["from_string"]=>
  bool(false)
}
8

object(DateInterval)#1 (10) {
  ["y"]=>
  int(0)
  ["m"]=>
  int(0)
  ["d"]=>
  int(9)
  ["h"]=>
  int(0)
  ["i"]=>
  int(0)
  ["s"]=>
  int(0)
  ["f"]=>
  float(0)
  ["invert"]=>
  int(0)
  ["days"]=>
  bool(false)
  ["from_string"]=>
  bool(false)
}
9

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$diff = $due_date->diff($today);

$months = $diff->format("%m");

$fine = 0.02 * $price * $months;

$bill = $price + $fine;
1

Daniellehr tại gmx dot de ¶

$due_date = new DateTime('13-02-2016');

$today = new DateTime();
$diff = $due_date->diff($today);

$months = ($diff->y * 12) + $diff->m;

echo $months;
3

object(DateInterval)#1 (16) {
  ["y"]=>
  int(0)
  ["m"]=>
  int(0)
  ["d"]=>
  int(9)
  ["h"]=>
  int(0)
  ["i"]=>
  int(0)
  ["s"]=>
  int(0)
  ["f"]=>
  float(0)
  ["weekday"]=>
  int(0)
  ["weekday_behavior"]=>
  int(0)
  ["first_last_day_of"]=>
  int(0)
  ["invert"]=>
  int(0)
  ["days"]=>
  bool(false)
  ["special_type"]=>
  int(0)
  ["special_amount"]=>
  int(0)
  ["have_weekday_relative"]=>
  int(0)
  ["have_special_relative"]=>
  int(0)
}
1

object(DateInterval)#1 (16) {
  ["y"]=>
  int(0)
  ["m"]=>
  int(0)
  ["d"]=>
  int(9)
  ["h"]=>
  int(0)
  ["i"]=>
  int(0)
  ["s"]=>
  int(0)
  ["f"]=>
  float(0)
  ["weekday"]=>
  int(0)
  ["weekday_behavior"]=>
  int(0)
  ["first_last_day_of"]=>
  int(0)
  ["invert"]=>
  int(0)
  ["days"]=>
  bool(false)
  ["special_type"]=>
  int(0)
  ["special_amount"]=>
  int(0)
  ["have_weekday_relative"]=>
  int(0)
  ["have_special_relative"]=>
  int(0)
}
2

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$diff = $due_date->diff($today);

$months = $diff->format("%m");

$fine = 0.02 * $price * $months;

$bill = $price + $fine;
1

Daniellehr tại gmx dot de ¶

kuzb ¶

object(DateInterval)#1 (16) {
  ["y"]=>
  int(0)
  ["m"]=>
  int(0)
  ["d"]=>
  int(9)
  ["h"]=>
  int(0)
  ["i"]=>
  int(0)
  ["s"]=>
  int(0)
  ["f"]=>
  float(0)
  ["weekday"]=>
  int(0)
  ["weekday_behavior"]=>
  int(0)
  ["first_last_day_of"]=>
  int(0)
  ["invert"]=>
  int(0)
  ["days"]=>
  bool(false)
  ["special_type"]=>
  int(0)
  ["special_amount"]=>
  int(0)
  ["have_weekday_relative"]=>
  int(0)
  ["have_special_relative"]=>
  int(0)
}
4

object(DateInterval)#1 (16) {
  ["y"]=>
  int(0)
  ["m"]=>
  int(0)
  ["d"]=>
  int(9)
  ["h"]=>
  int(0)
  ["i"]=>
  int(0)
  ["s"]=>
  int(0)
  ["f"]=>
  float(0)
  ["weekday"]=>
  int(0)
  ["weekday_behavior"]=>
  int(0)
  ["first_last_day_of"]=>
  int(0)
  ["invert"]=>
  int(0)
  ["days"]=>
  bool(false)
  ["special_type"]=>
  int(0)
  ["special_amount"]=>
  int(0)
  ["have_weekday_relative"]=>
  int(0)
  ["have_special_relative"]=>
  int(0)
}
5

object(DateInterval)#1 (16) {
  ["y"]=>
  int(0)
  ["m"]=>
  int(0)
  ["d"]=>
  int(9)
  ["h"]=>
  int(0)
  ["i"]=>
  int(0)
  ["s"]=>
  int(0)
  ["f"]=>
  float(0)
  ["weekday"]=>
  int(0)
  ["weekday_behavior"]=>
  int(0)
  ["first_last_day_of"]=>
  int(0)
  ["invert"]=>
  int(0)
  ["days"]=>
  bool(false)
  ["special_type"]=>
  int(0)
  ["special_amount"]=>
  int(0)
  ["have_weekday_relative"]=>
  int(0)
  ["have_special_relative"]=>
  int(0)
}
6

object(DateInterval)#1 (16) {
  ["y"]=>
  int(0)
  ["m"]=>
  int(0)
  ["d"]=>
  int(9)
  ["h"]=>
  int(0)
  ["i"]=>
  int(0)
  ["s"]=>
  int(0)
  ["f"]=>
  float(0)
  ["weekday"]=>
  int(0)
  ["weekday_behavior"]=>
  int(0)
  ["first_last_day_of"]=>
  int(0)
  ["invert"]=>
  int(0)
  ["days"]=>
  bool(false)
  ["special_type"]=>
  int(0)
  ["special_amount"]=>
  int(0)
  ["have_weekday_relative"]=>
  int(0)
  ["have_special_relative"]=>
  int(0)
}
7

object(DateInterval)#1 (16) {
  ["y"]=>
  int(0)
  ["m"]=>
  int(0)
  ["d"]=>
  int(9)
  ["h"]=>
  int(0)
  ["i"]=>
  int(0)
  ["s"]=>
  int(0)
  ["f"]=>
  float(0)
  ["weekday"]=>
  int(0)
  ["weekday_behavior"]=>
  int(0)
  ["first_last_day_of"]=>
  int(0)
  ["invert"]=>
  int(0)
  ["days"]=>
  bool(false)
  ["special_type"]=>
  int(0)
  ["special_amount"]=>
  int(0)
  ["have_weekday_relative"]=>
  int(0)
  ["have_special_relative"]=>
  int(0)
}
8

jawzx01 tại gmail dot com ¶

Quản trị viên tại Torntech dot com

7 năm trước

object(DateInterval)#1 (16) {
  ["y"]=>
  int(0)
  ["m"]=>
  int(0)
  ["d"]=>
  int(2)
  ["h"]=>
  int(0)
  ["i"]=>
  int(0)
  ["s"]=>
  int(0)
  ["f"]=>
  float(0)
  ["weekday"]=>
  int(0)
  ["weekday_behavior"]=>
  int(0)
  ["first_last_day_of"]=>
  int(0)
  ["invert"]=>
  int(0)
  ["days"]=>
  bool(false)
  ["special_type"]=>
  int(0)
  ["special_amount"]=>
  int(0)
  ["have_weekday_relative"]=>
  int(0)
  ["have_special_relative"]=>
  int(0)
}
0

object(DateInterval)#1 (16) {
  ["y"]=>
  int(0)
  ["m"]=>
  int(0)
  ["d"]=>
  int(2)
  ["h"]=>
  int(0)
  ["i"]=>
  int(0)
  ["s"]=>
  int(0)
  ["f"]=>
  float(0)
  ["weekday"]=>
  int(0)
  ["weekday_behavior"]=>
  int(0)
  ["first_last_day_of"]=>
  int(0)
  ["invert"]=>
  int(0)
  ["days"]=>
  bool(false)
  ["special_type"]=>
  int(0)
  ["special_amount"]=>
  int(0)
  ["have_weekday_relative"]=>
  int(0)
  ["have_special_relative"]=>
  int(0)
}
1

object(DateInterval)#1 (16) {
  ["y"]=>
  int(0)
  ["m"]=>
  int(0)
  ["d"]=>
  int(2)
  ["h"]=>
  int(0)
  ["i"]=>
  int(0)
  ["s"]=>
  int(0)
  ["f"]=>
  float(0)
  ["weekday"]=>
  int(0)
  ["weekday_behavior"]=>
  int(0)
  ["first_last_day_of"]=>
  int(0)
  ["invert"]=>
  int(0)
  ["days"]=>
  bool(false)
  ["special_type"]=>
  int(0)
  ["special_amount"]=>
  int(0)
  ["have_weekday_relative"]=>
  int(0)
  ["have_special_relative"]=>
  int(0)
}
2

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$diff = $due_date->diff($today);

$months = $diff->format("%m");

$fine = 0.02 * $price * $months;

$bill = $price + $fine;
1

4 năm trước

object(DateInterval)#1 (16) {
  ["y"]=>
  int(0)
  ["m"]=>
  int(0)
  ["d"]=>
  int(2)
  ["h"]=>
  int(0)
  ["i"]=>
  int(0)
  ["s"]=>
  int(0)
  ["f"]=>
  float(0)
  ["weekday"]=>
  int(0)
  ["weekday_behavior"]=>
  int(0)
  ["first_last_day_of"]=>
  int(0)
  ["invert"]=>
  int(0)
  ["days"]=>
  bool(false)
  ["special_type"]=>
  int(0)
  ["special_amount"]=>
  int(0)
  ["have_weekday_relative"]=>
  int(0)
  ["have_special_relative"]=>
  int(0)
}
3

object(DateInterval)#1 (16) {
  ["y"]=>
  int(0)
  ["m"]=>
  int(0)
  ["d"]=>
  int(2)
  ["h"]=>
  int(0)
  ["i"]=>
  int(0)
  ["s"]=>
  int(0)
  ["f"]=>
  float(0)
  ["weekday"]=>
  int(0)
  ["weekday_behavior"]=>
  int(0)
  ["first_last_day_of"]=>
  int(0)
  ["invert"]=>
  int(0)
  ["days"]=>
  bool(false)
  ["special_type"]=>
  int(0)
  ["special_amount"]=>
  int(0)
  ["have_weekday_relative"]=>
  int(0)
  ["have_special_relative"]=>
  int(0)
}
4

object(DateInterval)#1 (16) {
  ["y"]=>
  int(0)
  ["m"]=>
  int(0)
  ["d"]=>
  int(2)
  ["h"]=>
  int(0)
  ["i"]=>
  int(0)
  ["s"]=>
  int(0)
  ["f"]=>
  float(0)
  ["weekday"]=>
  int(0)
  ["weekday_behavior"]=>
  int(0)
  ["first_last_day_of"]=>
  int(0)
  ["invert"]=>
  int(0)
  ["days"]=>
  bool(false)
  ["special_type"]=>
  int(0)
  ["special_amount"]=>
  int(0)
  ["have_weekday_relative"]=>
  int(0)
  ["have_special_relative"]=>
  int(0)
}
5

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$diff = $due_date->diff($today);

$months = $diff->format("%m");

$fine = 0.02 * $price * $months;

$bill = $price + $fine;
1

Kevinpeno tại Gmail Dot Com ¶

$due_date = new DateTime('13-02-2016');

$today = new DateTime();
$diff = $due_date->diff($today);

$months = ($diff->y * 12) + $diff->m;

echo $months;
3

object(DateInterval)#1 (16) {
  ["y"]=>
  int(0)
  ["m"]=>
  int(0)
  ["d"]=>
  int(2)
  ["h"]=>
  int(0)
  ["i"]=>
  int(0)
  ["s"]=>
  int(0)
  ["f"]=>
  float(0)
  ["weekday"]=>
  int(0)
  ["weekday_behavior"]=>
  int(0)
  ["first_last_day_of"]=>
  int(0)
  ["invert"]=>
  int(0)
  ["days"]=>
  bool(false)
  ["special_type"]=>
  int(0)
  ["special_amount"]=>
  int(0)
  ["have_weekday_relative"]=>
  int(0)
  ["have_special_relative"]=>
  int(0)
}
7

object(DateInterval)#1 (16) {
  ["y"]=>
  int(0)
  ["m"]=>
  int(0)
  ["d"]=>
  int(2)
  ["h"]=>
  int(0)
  ["i"]=>
  int(0)
  ["s"]=>
  int(0)
  ["f"]=>
  float(0)
  ["weekday"]=>
  int(0)
  ["weekday_behavior"]=>
  int(0)
  ["first_last_day_of"]=>
  int(0)
  ["invert"]=>
  int(0)
  ["days"]=>
  bool(false)
  ["special_type"]=>
  int(0)
  ["special_amount"]=>
  int(0)
  ["have_weekday_relative"]=>
  int(0)
  ["have_special_relative"]=>
  int(0)
}
8

$due_date = new DateTime($_POST['due_date']);

$today = new DateTime();
$diff = $due_date->diff($today);

$months = $diff->format("%m");

$fine = 0.02 * $price * $months;

$bill = $price + $fine;
1