datetime - Exact styling of a difference in time (php) -
Two times (format: I tried it this way: But that output: 6: 14: 2 I think it does not look good. I want to see it: I also want to use the current time instead of a given time, but what does not work with the above code I noticed This output: Fatal Error: Call the diff () member function on a non-object I have twice: one time current time: H: i: s ), I found another question on this site.
$ start_date = new date time ('04: 10: 58 '); $ Since_start = $ start_date- & gt; Vary (new date time ('10: 25: 00 ')); Echo $ from_start-> H. ':'; Echo $ from_start-> I. ':'; Echo $ from_start-> S;
06:14:02
$ start_date = date ("h: i: s"); $ Since_start = $ start_date- & gt; Vary (new date time ('10: 25: 00 ')); Echo $ from_start-> H. ':'; Echo $ from_start-> I. ':'; Echo $ from_start-> S;
date ("H: I: s")
, second is a $ time0
in which for example 11 : 24: 00
(from a database).
internal date inward
is formatted, and you should use the function :
$ start_date = new date time ('04: 10: 58 '); $ Since_start = $ start_date- & gt; Vary (new date time ('10: 25: 00 ')); $ Resonance-$ d-> format ('% H:% I:% S'); For the second example, you are using a PHP string (since date ()
returns a string, not an object) and trying to treat it in this way. DateTime
object that causes you to get an error, you should instead start an empty datetime
object which will be the default for
: $ start_date = new dateTime (); // or datetime ('now') from $ $ - $ start_date- & gt; Diff (new date time ('10: 25: 00 ')); $ Resonance-$ d-> format ('% H:% I:% S');
If you are starting the $ start_date
value from a database, then assume that $ time0
You can send DateTime
, which will whistle on converting it to the appropriate dateTime
object:
$ start_date = new date time ( $ Time0)); $ Since_start = $ start_date- & gt; Vary (new date time ('10: 25: 00 ')); $ Resonance-$ d-> format ('% H:% I:% S');
Comments
Post a Comment