Languages :: PHP :: php timetostr |
|||
| By: Nono |
Date: 21/09/2005 09:29:03 |
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 | 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 |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








