visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Languages :: PHP :: php timetostr


By: Nono Great Britain  Date: 21/09/2005 09:29:03  English  Points: 20 Status: Answered
Quality : Excellent
Hello,

I'm searching for a function timetostr() in PHP, like the one in Delphi. Is there a way ?
By: VGR Date: 21/09/2005 09:47:36 English  Type : Answer
Hi ;-)

The Delphi standard function is defined like this :

TimeToStr Converts a variable of type TDateTime to a string

And TDateTime is a real type declared in the System unit (considered as a Double precision integer, ie 64 bits if my memory is not in default)

The equivalent exists in PHP and is called date() which operates on the integer return type of the function time() (with microseconds excluded, see microtime() if needed) int time ( void )

Interesting examples :

echo date('Y-m-d H:i:s'); // standard ISO datetimestamp //It's the equivalent of date('Y-m-d H:i:s',time()); or with mktime() : $tomorrow = mktime( 0,0,0,date('m'),date('d')+1,date('Y') ); The most classical way of doing TimeToStr() is : date("some format",mktime("split timestamp")); because mktime is defined as : int mktime ( [int hour [, int minute [, int second [, int month [, int day [, int year [, int is_dst]]]]]]] )



The reverse operation is much more interesting, namely StrToTime()

regards

Do register to be able to answer

EContact
browser fav
page generated in 984.264850 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page