-2

one question to converting datetime type from mysql which range starts from 1001-01-01 00:00. Problem is the day starts from 1 day but I would like to have it from 0 days. When I subtract day with -1 I get day 30.

$data['duration'] = date('d - H:i', strtotime($data['duration']));

This will output 01 - 00:00 but I would like to have 00 - 00:00

Any ideas ?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
marhyno
  • 677
  • 1
  • 8
  • 20

2 Answers2

0

As i've as a comment there is no 0 day. http://dev.mysql.com/doc/refman/5.6/en/datetime.html

The DATE type is used for values with a date part but no time part. MySQL retrieves and displays DATE values in 'YYYY-MM-DD' format. The supported range is '1000-01-01' to '9999-12-31'.

The DATETIME type is used for values that contain both date and time parts. MySQL retrieves and displays DATETIME values in 'YYYY-MM-DD HH:MM:SS' format. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'.

The TIMESTAMP data type is used for values that contain both date and time parts. TIMESTAMP has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC.

Also

Invalid DATE, DATETIME, or TIMESTAMP values are converted to the “zero” value of the appropriate type ('0000-00-00' or '0000-00-00 00:00:00').

MySQL does not accept TIMESTAMP values that include a zero in the day or month column or values that are not a valid date. The sole exception to this rule is the special “zero” value '0000-00-00 00:00:00'.

Bogdan
  • 693
  • 7
  • 26
0

Question answered - if hours are greater than 24 hours = I will display also 1 day. Otherwise only time is displayed

marhyno
  • 677
  • 1
  • 8
  • 20