Re: [PHP] About date & time...

2006-03-01 Thread Gustav Wiberg


- Original Message - 
From: "Marcus Gnaß" <[EMAIL PROTECTED]>

To: "Gustav Wiberg" <[EMAIL PROTECTED]>
Sent: Wednesday, March 01, 2006 5:24 PM
Subject: Re: [PHP] About date & time...



Gustav Wiberg schrieb:

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;

}

Although beeing a totally noob to PHP I suggest this instead:
function currenttime() {return date('H\:i\:s');}
function currentdate() {return date('Y\-m\-d');}

Marcus


Why?

return date('H\:i\:s') doesn't work as expected... :-)

/G

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] About date & time...

2006-02-28 Thread Gustav Wiberg


- Original Message - 
From: "tedd" <[EMAIL PROTECTED]>

To: ; "Gustav Wiberg" <[EMAIL PROTECTED]>
Sent: Tuesday, February 28, 2006 11:34 PM
Subject: Re: [PHP] About date & time...



Gustav:


I'm a swede, and I we use hours 0 - 24.


Well... I don't know what I am, but non sum qualis eram.

In any event, you want military time -- simple enough -- just change the h 
to H, like so:


  echo("Time: " . date('H\:\ i\:\ s') . "" );

You can find more code examples at:

http://www.weberdev.com/AdvancedSearch.php?searchtype=title&search=date&Submit1.x=0&Submit1.y=0

Also, you need to review the php manual regarding date() -- it's a super 
function that has lot's of formatting symbols.


tedd

--

http://sperling.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Yes, thanx! I've totally missed the part about 12/24-h setting... :-)

/G

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] About date & time...

2006-02-28 Thread Gustav Wiberg


- Original Message - 
From: "Grant Young" <[EMAIL PROTECTED]>

To: 
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, February 28, 2006 11:25 PM
Subject: Re: [PHP] About date & time...



Hi Gustav.



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...)


The docs for date() (http://www.php.net/date) show that there are a 
number of different options for the first parameter.  If you check out 
the table on that page, you'll find:


>> H | 24-hour format of an hour with leading zeros | 00 through 23

With this in mind, the following will work (if I understand your 
question correctly):


$t = date('H\:\ i\:\ s');

HTH, Grant


AHA!!!

Sometimes I'm so stupid... hm...

Thanx! :-)

/G

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] About date & time...

2006-02-28 Thread tedd

Gustav:


I'm a swede, and I we use hours 0 - 24.


Well... I don't know what I am, but non sum qualis eram.

In any event, you want military time -- simple enough -- just change 
the h to H, like so:


  echo("Time: " . date('H\:\ i\:\ s') . "" );

You can find more code examples at:

http://www.weberdev.com/AdvancedSearch.php?searchtype=title&search=date&Submit1.x=0&Submit1.y=0

Also, you need to review the php manual regarding date() -- it's a 
super function that has lot's of formatting symbols.


tedd

--

http://sperling.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] About date & time...

2006-02-28 Thread Grant Young

Hi Gustav.



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...)


The docs for date() (http://www.php.net/date) show that there are a 
number of different options for the first parameter.  If you check out 
the table on that page, you'll find:


>> H | 24-hour format of an hour with leading zeros | 00 through 23

With this in mind, the following will work (if I understand your 
question correctly):


$t = date('H\:\ i\:\ s');

HTH, Grant

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] About date & time...

2006-02-28 Thread Gustav Wiberg


- Original Message - 
From: "tedd" <[EMAIL PROTECTED]>

To: ; "Gustav Wiberg" <[EMAIL PROTECTED]>
Sent: Tuesday, February 28, 2006 4:17 PM
Subject: Re: [PHP] About date & time...



>Thanx for your input about date & time...


Here'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') . "" );

and your -- function currentdate()

can be replaced with:

echo("Time: " . date('h\:\ i\:\ s') . "" );

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. "" );

and

$date = date('h\:\ i\:\ s') ;
$date = str_replace(" ", "", $date);
echo("Time: " . $date. "" );

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


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...)

/G

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] About date & time...

2006-02-28 Thread Gustav Wiberg


- Original Message - 
From: "tedd" <[EMAIL PROTECTED]>

To: ; "Gustav Wiberg" <[EMAIL PROTECTED]>
Sent: Tuesday, February 28, 2006 4:17 PM
Subject: Re: [PHP] About date & time...



>Thanx for your input about date & time...


Here'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') . "" );

and your -- function currentdate()

can be replaced with:

echo("Time: " . date('h\:\ i\:\ s') . "" );

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. "" );

and

$date = date('h\:\ i\:\ s') ;
$date = str_replace(" ", "", $date);
echo("Time: " . $date. "" );

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


Hi there!

Not meaning to embarrass, but your code could be shortened considerably by 
using date(), like so:
*hehe* It's all okey, it was something like this you're typing that I was 
searching for, but couldn't find it exactly as I wanted. Thanx a lot!!! :-) 
I really appreciate it!


/G 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] About date & time...

2006-02-28 Thread tedd

Thanx for your input about date & time...

Here'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') . "" );

and your -- function currentdate()

can be replaced with:

echo("Time: " . date('h\:\ i\:\ s') . "" );

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. "" );

and

$date = date('h\:\ i\:\ s') ;
$date = str_replace(" ", "", $date);
echo("Time: " . $date. "" );

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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] About date & time...

2006-02-28 Thread Andrei
I don't understand! Why don't u use date function and just format it as 
u want?


Andy

Gustav Wiberg wrote:

Hi

Thanx for your input about date & time...

Here's some functions that worked for me after some searching...


function currenttime() {

$today = getdate();

$ithours = $today["hours"];
if (intval($ithours)<10) {
 $ithours = "0" . $ithours;
}

$itminutes = $today["minutes"];
if (intval($ithours)<10) {
 $ithours = "0" . $ithours;
}

$itseconds = $today["seconds"];
if (intval($itseconds)<10) {
 $itseconds = "0" . $itseconds;
}


$it = $ithours . ":" . $itminutes . ":" . $itseconds;
return $it;
}

function currentdate() {

$today = getdate();

$idyear = $today["year"];
if (intval($idyear)<10) {
 $idyear = "0" . $idyear;
}

$idmonthnr = $today["mon"];
if (intval($idmonthnr )<10) {
 $idmonthnr  = "0" . $idmonthnr ;
}

$idmonthday = $today["mday"];
if (intval($idmonthday)<10) {
 $idmonthday = "0" . $idmonthday;
}


$id = $idyear . "-" . $idmonthnr . "-" . $idmonthday;
return $id;

}

$insertTime = currenttime();
$insertDate = currentdate();



/G



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] About date & time...

2006-02-28 Thread Gustav Wiberg

Hi

Thanx for your input about date & time...

Here's some functions that worked for me after some searching...


function currenttime() {

$today = getdate();

$ithours = $today["hours"];
if (intval($ithours)<10) {
 $ithours = "0" . $ithours;
}

$itminutes = $today["minutes"];
if (intval($ithours)<10) {
 $ithours = "0" . $ithours;
}

$itseconds = $today["seconds"];
if (intval($itseconds)<10) {
 $itseconds = "0" . $itseconds;
}


$it = $ithours . ":" . $itminutes . ":" . $itseconds;
return $it;
}

function currentdate() {

$today = getdate();

$idyear = $today["year"];
if (intval($idyear)<10) {
 $idyear = "0" . $idyear;
}

$idmonthnr = $today["mon"];
if (intval($idmonthnr )<10) {
 $idmonthnr  = "0" . $idmonthnr ;
}

$idmonthday = $today["mday"];
if (intval($idmonthday)<10) {
 $idmonthday = "0" . $idmonthday;
}


$id = $idyear . "-" . $idmonthnr . "-" . $idmonthday;
return $id;

}

$insertTime = currenttime();
$insertDate = currentdate();



/G

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php