Re: About date & time...
| From: | Gustav Wiberg | Date: | Tue, 28 Feb 2006 22:00:53 +0000 |
| Subject: | Re: About date & time... | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-231234@lists.php.net to get a copy of this message | ||
----- Original Message ----- From: "tedd" <tedd@sperling.com>
To: <php-general@lists.php.net>; "Gustav Wiberg" <gustav@varupiraten.se>
Sent: Tuesday, February 28, 2006 4:17 PM
Subject: Re: [PHP] About date & time...
Thanx for your input about date & time...Hi there! I've now done coding like this... function currenttime() { $t = date('h\:\ i\:\ s'); $returnTime = str_replace(" ", "", $t); return $returnTime; } function currentdate() { $d = date('Y\-\ m\-\ d'); $returnDate = str_replace(" ", "", $d); return $returnDate; } $insertTime = currenttime(); $insertDate = currentdate(); I'm a swede, and I we use hours 0 - 24. 8 pm = 20 for us. 9 pm = 21 for us 10 pm = 22... and so on... But with date()-function there is 10 pm that shows (and I want 22 to show instead) I'm using PHP 4.0.3... Do I have to use getdate() then? (getdate()-function showed 22...) /GHere's some functions that worked for me after some searching... function currenttime() { -snip- lot's of code.Hi Gustav: Not meaning to embarrass, but your code could be shortened considerably by using date(), like so: Your lengthy -- function currenttime() can be replaced simply with: echo("Date: " . date('Y\-\ m\-\ d') . "<br/>" ); and your -- function currentdate() can be replaced with:echo("Time: " . date('h\:\ i\:\ s') . "<br/>" );If you don't like the spaces in the output, then strip them out, like so:$date = date('Y\-\ m\-\ d'); $date = str_replace(" ", "", $date); echo("Date: " . $date. "<br/>" );and$date = date('h\:\ i\:\ s') ; $date = str_replace(" ", "", $date); echo("Time: " . $date. "<br/>" );You can find more code examples at: http://www.weberdev.com/AdvancedSearch.php?searchtype=title&search=date&Submit1.x=0&Submit1.y=0 tedd -- -------------------------------------------------------------------------------- http://sperling.com