Re: [PHP] Time Problem: always ten past xx

2009-10-06 Thread tedd

At 10:07 AM +0200 10/6/09, Matthias Laug wrote:

argh, why do I always stick to the stupid questions :( sorry


Because with the important questions, you don't need answers. You 
understand them.


Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Time Problem: always ten past xx

2009-10-06 Thread Tom Worster
On 10/6/09 4:16 AM, "Mert Oztekin"  wrote:

> My mistake,
> 
> I thought it was date() now strftime()
> Sorry
> 
> (why do php developers create two different standarts for such similiar
> functions???☺ )
> 

it's traditional to do so. it reminds me of the bit about subtly
incompatible shells in unix from "Real Programmers Don't Use Pascal":

"Even Unix might not be as bad on Real Programmers as it once was. The
latest release of Unix has the potential of an operating system worthy of
any Real Programmer-- two different and subtly incompatible user interfaces,
an arcane and complicated teletype driver, virtual memory. If you ignore the
fact that it's "structured", even 'C' programming can be appreciated by the
Real Programmer: after all, there's no type checking, variable names are
seven (ten? eight?) characters long, and the added bonus of the Pointer data
type is thrown in-- like having the best parts of Fortran and assembly
language in one place. (Not to mention some of the more creative uses for
#define.)"

we could collect a list:

gnu make vs bsd make
how many subtly different versions of grep are there?


but i'm, sure it's been done already and i guess it's off topic.



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



RE: [PHP] Time Problem: always ten past xx

2009-10-06 Thread Jason
Hi Mert,

But we're not talking about date() here, we're talking strftime().

According to the manual %i doesn't do anything in strftime(). Closest match
is %I which is 12-hour format for hours.

HTH
J

-Original Message-
From: Mert Oztekin [mailto:mozte...@anadolusigorta.com.tr] 
Sent: 06 October 2009 09:07
To: 'Jason'; 'Matthias Laug'; php-general@lists.php.net
Subject: RE: [PHP] Time Problem: always ten past xx

Jason,

%M is also month:

Month --- ---
F A full textual representation of a month, such as January or March January
through December
m Numeric representation of a month, with leading zeros 01 through 12
M A short textual representation of a month, three letters Jan through Dec
n Numeric representation of a month, without leading zeros 1 through 12
t Number of days in the given month 28 through 31

Time --- ---
i Minutes with leading zeros 00 to 59

http://tr.php.net/manual/en/function.date.php



-Original Message-
From: Jason [mailto:networkad...@emarket2.com]
Sent: Tuesday, October 06, 2009 11:04 AM
To: 'Matthias Laug'; php-general@lists.php.net
Subject: RE: [PHP] Time Problem: always ten past xx

Hi,

That's because %m is month, what you need is %M for minute (note uppercase).

Check out http://php.net/strftime

HTH
J

-Original Message-
From: Matthias Laug [mailto:matthias.l...@gmail.com]
Sent: 06 October 2009 08:53
To: php-general@lists.php.net
Subject: [PHP] Time Problem: always ten past xx

Hey everybody,

I've got a strange problem. Using PHP5.3 on my MacBook.

There is a script, which handles input from user, in this case a date
and time.

So I get for example "10:30" and "06.10.2009". Standard german time
format. Now I try to get the correct timestamp:

$time = strtotime("06.10.2009 10:30");
var_dump($time);
var_dump(strftime("%d.%m.%Y %H:%m",$time));

But the result is as

int 1254817800
string '06.10.2009 10:10' (length=16)

The minutes are always "10", no matter what time I get.

Anyone a clue?

Thanks, Mattes

P.S.: default timezone is set to

date_default_timezone_set('Europe/Berlin');



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


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



  
Bu mesaj ve ekleri, mesajda g?nderildi?i belirtilen ki?i/ki?ilere ?zeldir ve
gizlidir. Size yanl??l?kla ula?m??sa l?tfen g?nderen kisiyi bilgilendiriniz
ve mesaj? sisteminizden siliniz. Mesaj ve eklerinin i?eri?i ile ilgili
olarak ?irketimizin herhangi bir hukuki sorumlulu?u bulunmamaktad?r.
?irketimiz mesaj?n ve bilgilerinin size de?i?ikli?e u?rayarak veya ge?
ula?mas?ndan, b?t?nl???n?n ve gizlili?inin korunamamas?ndan, vir?s
i?ermesinden ve bilgisayar sisteminize verebilece?i herhangi bir zarardan
sorumlu tutulamaz.

This message and attachments are confidential and intended for the
individual(s) stated in this message. If you received this message in error,
please immediately notify the sender and delete it from your system. Our
company has no legal responsibility for the contents of the message and its
attachments. Our company shall have no liability for any changes or late
receiving, loss of integrity and confidentiality, viruses and any damages
caused in anyway to your computer system.


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



RE: [PHP] Time Problem: always ten past xx

2009-10-06 Thread Mert Oztekin
My mistake,

I thought it was date() now strftime()
Sorry

(why do php developers create two different standarts for such similiar 
functions???☺ )

_
From: Mert Oztekin
Sent: Tuesday, October 06, 2009 11:07 AM
To: 'Jason'; 'Matthias Laug'; php-general@lists.php.net
Subject: RE: [PHP] Time Problem: always ten past xx


Jason,

%M is also month:

Month --- ---
F A full textual representation of a month, such as January or March January 
through December
m Numeric representation of a month, with leading zeros 01 through 12
M A short textual representation of a month, three letters Jan through Dec
n Numeric representation of a month, without leading zeros 1 through 12
t Number of days in the given month 28 through 31

Time --- ---
i Minutes with leading zeros 00 to 59

http://tr.php.net/manual/en/function.date.php



-Original Message-
From: Jason [mailto:networkad...@emarket2.com]
Sent: Tuesday, October 06, 2009 11:04 AM
To: 'Matthias Laug'; php-general@lists.php.net
Subject: RE: [PHP] Time Problem: always ten past xx

Hi,

That's because %m is month, what you need is %M for minute (note uppercase).

Check out http://php.net/strftime

HTH
J

-Original Message-
From: Matthias Laug [mailto:matthias.l...@gmail.com]
Sent: 06 October 2009 08:53
To: php-general@lists.php.net
Subject: [PHP] Time Problem: always ten past xx

Hey everybody,

I've got a strange problem. Using PHP5.3 on my MacBook.

There is a script, which handles input from user, in this case a date
and time.

So I get for example "10:30" and "06.10.2009". Standard german time
format. Now I try to get the correct timestamp:

$time = strtotime("06.10.2009 10:30");
var_dump($time);
var_dump(strftime("%d.%m.%Y %H:%m",$time));

But the result is as

int 1254817800
string '06.10.2009 10:10' (length=16)

The minutes are always "10", no matter what time I get.

Anyone a clue?

Thanks, Mattes

P.S.: default timezone is set to

date_default_timezone_set('Europe/Berlin');



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


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



  
Bu mesaj ve ekleri, mesajda gönderildiği belirtilen kişi/kişilere özeldir ve 
gizlidir. Size yanlışlıkla ulaşmışsa lütfen gönderen kisiyi bilgilendiriniz ve 
mesajı sisteminizden siliniz. Mesaj ve eklerinin içeriği ile ilgili olarak 
şirketimizin herhangi bir hukuki sorumluluğu bulunmamaktadır. Şirketimiz 
mesajın ve bilgilerinin size değişikliğe uğrayarak veya geç ulaşmasından, 
bütünlüğünün ve gizliliğinin korunamamasından, virüs içermesinden ve bilgisayar 
sisteminize verebileceği herhangi bir zarardan sorumlu tutulamaz.

This message and attachments are confidential and intended for the 
individual(s) stated in this message. If you received this message in error, 
please immediately notify the sender and delete it from your system. Our 
company has no legal responsibility for the contents of the message and its 
attachments. Our company shall have no liability for any changes or late 
receiving, loss of integrity and confidentiality, viruses and any damages 
caused in anyway to your computer system.


RE: [PHP] Time Problem: always ten past xx

2009-10-06 Thread Mert Oztekin
Jason,

%M is also month:

Month --- ---
F A full textual representation of a month, such as January or March January 
through December
m Numeric representation of a month, with leading zeros 01 through 12
M A short textual representation of a month, three letters Jan through Dec
n Numeric representation of a month, without leading zeros 1 through 12
t Number of days in the given month 28 through 31

Time --- ---
i Minutes with leading zeros 00 to 59

http://tr.php.net/manual/en/function.date.php



-Original Message-
From: Jason [mailto:networkad...@emarket2.com]
Sent: Tuesday, October 06, 2009 11:04 AM
To: 'Matthias Laug'; php-general@lists.php.net
Subject: RE: [PHP] Time Problem: always ten past xx

Hi,

That's because %m is month, what you need is %M for minute (note uppercase).

Check out http://php.net/strftime

HTH
J

-Original Message-
From: Matthias Laug [mailto:matthias.l...@gmail.com]
Sent: 06 October 2009 08:53
To: php-general@lists.php.net
Subject: [PHP] Time Problem: always ten past xx

Hey everybody,

I've got a strange problem. Using PHP5.3 on my MacBook.

There is a script, which handles input from user, in this case a date
and time.

So I get for example "10:30" and "06.10.2009". Standard german time
format. Now I try to get the correct timestamp:

$time = strtotime("06.10.2009 10:30");
var_dump($time);
var_dump(strftime("%d.%m.%Y %H:%m",$time));

But the result is as

int 1254817800
string '06.10.2009 10:10' (length=16)

The minutes are always "10", no matter what time I get.

Anyone a clue?

Thanks, Mattes

P.S.: default timezone is set to

date_default_timezone_set('Europe/Berlin');



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


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



  
Bu mesaj ve ekleri, mesajda g?nderildi?i belirtilen ki?i/ki?ilere ?zeldir ve 
gizlidir. Size yanl??l?kla ula?m??sa l?tfen g?nderen kisiyi bilgilendiriniz ve 
mesaj? sisteminizden siliniz. Mesaj ve eklerinin i?eri?i ile ilgili olarak 
?irketimizin herhangi bir hukuki sorumlulu?u bulunmamaktad?r. ?irketimiz 
mesaj?n ve bilgilerinin size de?i?ikli?e u?rayarak veya ge? ula?mas?ndan, 
b?t?nl???n?n ve gizlili?inin korunamamas?ndan, vir?s i?ermesinden ve bilgisayar 
sisteminize verebilece?i herhangi bir zarardan sorumlu tutulamaz.

This message and attachments are confidential and intended for the 
individual(s) stated in this message. If you received this message in error, 
please immediately notify the sender and delete it from your system. Our 
company has no legal responsibility for the contents of the message and its 
attachments. Our company shall have no liability for any changes or late 
receiving, loss of integrity and confidentiality, viruses and any damages 
caused in anyway to your computer system.


Re: [PHP] Time Problem: always ten past xx

2009-10-06 Thread Matthias Laug

argh, why do I always stick to the stupid questions :( sorry

Am 06.10.2009 um 10:03 schrieb Mert Oztekin:


You also write the answer

var_dump(strftime("%d.%m.%Y %H:%m",$time));

there are 2 %m  you see? %m is month :)

for minute use %i


-Original Message-
From: Matthias Laug [mailto:matthias.l...@gmail.com]
Sent: Tuesday, October 06, 2009 10:53 AM
To: php-general@lists.php.net
Subject: [PHP] Time Problem: always ten past xx

Hey everybody,

I've got a strange problem. Using PHP5.3 on my MacBook.

There is a script, which handles input from user, in this case a date
and time.

So I get for example "10:30" and "06.10.2009". Standard german time
format. Now I try to get the correct timestamp:

$time = strtotime("06.10.2009 10:30");
var_dump($time);
var_dump(strftime("%d.%m.%Y %H:%m",$time));

But the result is as

int 1254817800
string '06.10.2009 10:10' (length=16)

The minutes are always "10", no matter what time I get.

Anyone a clue?

Thanks, Mattes

P.S.: default timezone is set to

date_default_timezone_set('Europe/Berlin');



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


  
Bu mesaj ve ekleri, mesajda gönderildiği belirtilen kişi/kişilere  
özeldir ve gizlidir. Size yanlışlıkla ulaşmışsa lütfen  
gönderen kisiyi bilgilendiriniz ve mesajı sisteminizden siliniz.  
Mesaj ve eklerinin içeriği ile ilgili olarak şirketimizin herhangi  
bir hukuki sorumluluğu bulunmamaktadır. Şirketimiz mesajın ve  
bilgilerinin size değişikliğe uğrayarak veya geç ulaşmasından,  
bütünlüğünün ve gizliliğinin korunamamasından, virüs  
içermesinden ve bilgisayar sisteminize verebileceği herhangi bir  
zarardan sorumlu tutulamaz.


This message and attachments are confidential and intended for the  
individual(s) stated in this message. If you received this message  
in error, please immediately notify the sender and delete it from  
your system. Our company has no legal responsibility for the  
contents of the message and its attachments. Our company shall have  
no liability for any changes or late receiving, loss of integrity  
and confidentiality, viruses and any damages caused in anyway to  
your computer system.


Matthias Laug
Schillerstraße 36
10627 Berlin

Tel.: 0176 / 20 14 21 63
eMail: matthias.l...@gmail.com





RE: [PHP] Time Problem: always ten past xx

2009-10-06 Thread Mert Oztekin
You also write the answer

var_dump(strftime("%d.%m.%Y %H:%m",$time));

there are 2 %m  you see? %m is month :)

for minute use %i


-Original Message-
From: Matthias Laug [mailto:matthias.l...@gmail.com]
Sent: Tuesday, October 06, 2009 10:53 AM
To: php-general@lists.php.net
Subject: [PHP] Time Problem: always ten past xx

Hey everybody,

I've got a strange problem. Using PHP5.3 on my MacBook.

There is a script, which handles input from user, in this case a date
and time.

So I get for example "10:30" and "06.10.2009". Standard german time
format. Now I try to get the correct timestamp:

$time = strtotime("06.10.2009 10:30");
var_dump($time);
var_dump(strftime("%d.%m.%Y %H:%m",$time));

But the result is as

int 1254817800
string '06.10.2009 10:10' (length=16)

The minutes are always "10", no matter what time I get.

Anyone a clue?

Thanks, Mattes

P.S.: default timezone is set to

date_default_timezone_set('Europe/Berlin');



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



  
Bu mesaj ve ekleri, mesajda g?nderildi?i belirtilen ki?i/ki?ilere ?zeldir ve 
gizlidir. Size yanl??l?kla ula?m??sa l?tfen g?nderen kisiyi bilgilendiriniz ve 
mesaj? sisteminizden siliniz. Mesaj ve eklerinin i?eri?i ile ilgili olarak 
?irketimizin herhangi bir hukuki sorumlulu?u bulunmamaktad?r. ?irketimiz 
mesaj?n ve bilgilerinin size de?i?ikli?e u?rayarak veya ge? ula?mas?ndan, 
b?t?nl???n?n ve gizlili?inin korunamamas?ndan, vir?s i?ermesinden ve bilgisayar 
sisteminize verebilece?i herhangi bir zarardan sorumlu tutulamaz.

This message and attachments are confidential and intended for the 
individual(s) stated in this message. If you received this message in error, 
please immediately notify the sender and delete it from your system. Our 
company has no legal responsibility for the contents of the message and its 
attachments. Our company shall have no liability for any changes or late 
receiving, loss of integrity and confidentiality, viruses and any damages 
caused in anyway to your computer system.


RE: [PHP] Time Problem: always ten past xx

2009-10-06 Thread Jason
Hi,

That's because %m is month, what you need is %M for minute (note uppercase).

Check out http://php.net/strftime 

HTH
J

-Original Message-
From: Matthias Laug [mailto:matthias.l...@gmail.com] 
Sent: 06 October 2009 08:53
To: php-general@lists.php.net
Subject: [PHP] Time Problem: always ten past xx

Hey everybody,

I've got a strange problem. Using PHP5.3 on my MacBook.

There is a script, which handles input from user, in this case a date  
and time.

So I get for example "10:30" and "06.10.2009". Standard german time  
format. Now I try to get the correct timestamp:

$time = strtotime("06.10.2009 10:30");
var_dump($time);
var_dump(strftime("%d.%m.%Y %H:%m",$time));

But the result is as

int 1254817800
string '06.10.2009 10:10' (length=16)

The minutes are always "10", no matter what time I get.

Anyone a clue?

Thanks, Mattes

P.S.: default timezone is set to

date_default_timezone_set('Europe/Berlin');



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


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



[PHP] Time Problem: always ten past xx

2009-10-06 Thread Matthias Laug

Hey everybody,

I've got a strange problem. Using PHP5.3 on my MacBook.

There is a script, which handles input from user, in this case a date  
and time.


So I get for example "10:30" and "06.10.2009". Standard german time  
format. Now I try to get the correct timestamp:


$time = strtotime("06.10.2009 10:30");
var_dump($time);
var_dump(strftime("%d.%m.%Y %H:%m",$time));

But the result is as

int 1254817800
string '06.10.2009 10:10' (length=16)

The minutes are always "10", no matter what time I get.

Anyone a clue?

Thanks, Mattes

P.S.: default timezone is set to

date_default_timezone_set('Europe/Berlin');



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



Re: [PHP] Time problem

2003-11-11 Thread John W. Holmes
Erin wrote:

Hi All,
Sorry if this has been asked a 1000 times and if its easy to find in the
php manual but i cant seam to solve this.
How do i convert a timestamp in to a normal readable time & date ie

2003155023

into

11th November 2003 @ 15:50:23
IFF the "timestamp" is coming from MySQL (which has that format), then 
you should use DATE_FORMAT() in your query to do the formatting.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

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


RE: [PHP] Time problem

2003-11-11 Thread Vail, Warren
Not sure how others would tackle this, but I would use something like

$readabledate = date("dS F Y @ H:i:s",
strtotime(substr($timestamp,0,4)."-"
 .substr($timestamp,4,2)."-"
 .substr($timestamp,6,2)." "
 .substr($timestamp,8,2).":"
 .substr($timestamp,10,2).":"
 .substr($timestamp,12,2)));

Not sure this is bug free, but it should change your timestamp (yes it is a
database timestamp) into the readable format you described.  It's yours to
debug.

http://www.php.net/manual/en/function.date.php

Good luck,

Warren Vail

-Original Message-
From: Erin [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 11, 2003 4:00 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Time problem


Hi All,
Sorry if this has been asked a 1000 times and if its easy to find in the
php manual but i cant seam to solve this.

How do i convert a timestamp in to a normal readable time & date ie

2003155023

into

11th November 2003 @ 15:50:23


Many thanks, thought id ask someone is bound to have a snippet for this.



Regards

All



Erin

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

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



Re: [PHP] Time problem

2003-11-11 Thread Chris Shiflett
--- Erin <[EMAIL PROTECTED]> wrote: 
> How do i convert a timestamp in to a normal readable time & date ie
> 
> 2003155023
> 
> into
> 
> 11th November 2003 @ 15:50:23

That's not a timestamp, first of all. It looks to me like you just need to
use substr() to parse out the elements however you want. You can see if
strtotime() can do anything with it, but I doubt it.

If you want to convert it to a real timestamp, look at the mktime()
function. Once you have a timestamp, it's very easy to work with, and you
can use date() to format it however you want.

Hope that helps.

Chris

=
My Blog
 http://shiflett.org/
HTTP Developer's Handbook
 http://httphandbook.org/
RAMP Training Courses
 http://www.nyphp.org/ramp

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



[PHP] Time problem

2003-11-11 Thread Erin
Hi All,
Sorry if this has been asked a 1000 times and if its easy to find in the
php manual but i cant seam to solve this.

How do i convert a timestamp in to a normal readable time & date ie

2003155023

into

11th November 2003 @ 15:50:23


Many thanks, thought id ask someone is bound to have a snippet for this.



Regards

All



Erin

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



RE: [PHP] time() problem

2002-09-18 Thread Adam Voigt

Change it to an INT or a VARCHAR datatype, the mysql timestamp field
uses MySQL's date/time formmating. If you decide to let MySQL use it's
own date time format, use UNIX_TIMESTAMP(fieldname) to get the unix
timestamp from that date field.

Adam Voigt
[EMAIL PROTECTED]

On Wed, 2002-09-18 at 13:19, Savaidis wrote:
> 
> 
> Hello all!
> 
> I use time() to keep UNIX seconds from 1970 to a timestamp(14) MySQL field.
> But when I read it (Dt_last) it is TO big compearing with "today=time()" in
> a php script that is only some seconds later.
> today : 1032350421 Dt_last: 20001101165838
> 
> What can I do?
> Thanks!
> Makis
> 
> 
> 
> Makis
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 



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




RE: [PHP] time() problem

2002-09-18 Thread Savaidis



Hello all!

I use time() to keep UNIX seconds from 1970 to a timestamp(14) MySQL field.
But when I read it (Dt_last) it is TO big compearing with "today=time()" in
a php script that is only some seconds later.
today : 1032350421 Dt_last: 20001101165838

What can I do?
Thanks!
Makis



Makis



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




Re: [PHP] Time problem

2001-08-08 Thread pierre-yves

Thanks, I feel a bit moron ;) it seems like I missed it while reading the
manuel,
sometimes the solution is so obvious that it becomes trivial!
py


- Original Message -
From: "Thomas Schmid" <[EMAIL PROTECTED]>
To: "'pierre-yves'" <[EMAIL PROTECTED]>
Sent: Wednesday, August 08, 2001 8:23 AM
Subject: AW: [PHP] Time problem


Take the date() function ;-)

-Ursprüngliche Nachricht-
Von: pierre-yves [mailto:[EMAIL PROTECTED]]
Gesendet: Mittwoch, 8. August 2001 14:19
An: [EMAIL PROTECTED]
Betreff: [PHP] Time problem

Hello,
I convert the time in seconds to do some calculations, now I want
to convert a number of seconds in a presentable HH:MM:SS format.

In other words, how do you change this 997271630.08651
in 08:14:32 ?

py

p.s. I use this to get the number of seconds.
function getmicrotime() {
  $temparray=split(" ",microtime());
  $returntime=$temparray[0]+$temparray[1];
  return $returntime;
}






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Time problem

2001-08-08 Thread Gianluca Baldo

Pierre -
py> In other words, how do you change this 997271630.08651
py> in 08:14:32 ?
you can use date() in conjunction with mktime().
Have a look at the manual there are good examples and users comments there.

Cheers,
   Gianluca

[EMAIL PROTECTED]

BcnInédita
EURO RSCG INTERACTION
www.bcninedita.com
Planella, 39
08017 Barcelona
Tel.34 932 531 950 (directo 93 253 19 53)
Fax. 34 932 114 546 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Time problem

2001-08-08 Thread pierre-yves

Hello,
I convert the time in seconds to do some calculations, now I want
to convert a number of seconds in a presentable HH:MM:SS format.

In other words, how do you change this 997271630.08651
in 08:14:32 ?

py

p.s. I use this to get the number of seconds.
function getmicrotime() { 
  $temparray=split(" ",microtime()); 
  $returntime=$temparray[0]+$temparray[1]; 
  return $returntime; 
}






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Time problem

2001-02-08 Thread Steve Werby

<[EMAIL PROTECTED]> wrote:
> Or you could do it the easy way in MySQL:
>
> SELECT SEC_TO_TIME( TIME_TO_SEC( OUT ) - TIME_TO_SEC( IN )) AS Hours,
> This requires IN and OUT to be type TIME.

That is a pretty sweet function and it's definitely faster to handle the
conversion in MySQL instead of PHP.  My example was for a datetime MySQL
field as opposed to a plain time field.  Like Rick Widmer stated, usage of
TIME_TO_SEC() only works correctly on time fields.  If your data is a
datetime field you can use UNIX_TIMESTAMP() to convert a field to seconds
since epoch.  Do that for two fields take the difference and divide by a
constant to convert into desired time units.

SELECT UNIX_TIMESTAMP("2001-01-14 16:49:34") => 979508974

--
Steve Werby
COO
24-7 Computer Services, LLC
Tel: 804.817.2470
http://www.247computing.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Time problem

2001-02-07 Thread php3

Addressed to: "Steve Werby" <[EMAIL PROTECTED]>
  "Roman" <[EMAIL PROTECTED]>
  "Php-General" <[EMAIL PROTECTED]>

** Reply to note from "Steve Werby" <[EMAIL PROTECTED]> Wed, 7 Feb 2001 09:28:29 
-0500

Or you could do it the easy way in MySQL:

SELECT SEC_TO_TIME( TIME_TO_SEC( OUT ) - TIME_TO_SEC( IN )) AS Hours,
..
..
..

This requires IN and OUT to be type TIME.




>
> "Roman" <[EMAIL PROTECTED]> wrote:
> > I have one problem with mysql database. In table i have 2 arrays with time
> > format.
> > For example this arrays calls IN and OUT. In php script i want to have
> > distinction between
> > this arrays. For example IN is 8:30:45 and OUT is 16:45:15 and result
> > will be: 8:14:30. Exists any function which do this. Tnanx.
>
> If your MySQL fields are a datetime type (-MM-DD hh:mm:ss) then you can
> convert them to seconds since epoch (Jan 1, 1970 at midnight) and then
> calculate the difference and divide by a number to get appropriate units.
> Below is a set of functions I wrote to do that.  Before I get to that here's
> a simpler solution:
>
> // $time = "16:45:15";
> $time_array = explode( ":", $time);
> // $time[0] = 16, $time[1] = 45, $time[2] = 15
> $time_since_midnight = $time[0] * 3600 + $time[1] * 60 + $time[2];
> // Do this conversion for both times, subtract and convert units.
>
> function get_mysql_to_epoch( $date )
> {
> list( $year, $month, $day, $hour, $minute, $second ) = split(
> "([^0-9])", $date );
> return date( "U", mktime( $hour, $minute, $second, $month, $day,
> $year ) );
> }
>
> function get_elapsed_time( $time_start, $time_end, $units = "seconds",
> $decimals = "2" )
> {
> $divider[years]   = ( 60 * 60 * 24 * 365 );
> $divider[months]  = ( 60 * 60 * 24 * 365 / 12 );
> $divider[weeks]   = ( 60 * 60 * 24 / 7 );
> $divider[days]= ( 60 * 60 * 24 );
> $divider[hours]   = ( 60 * 60 );
> $divider[minutes] = ( 60 );
> $divider[seconds] = 1;
>
> $elapsed_time = ( ( get_mysql_to_epoch( $time_end ) -
> get_mysql_to_epoch( $time_start ) )
>   / $divider[$units] );
> $elapsed_time = sprintf( "%0.{$decimals}f", $elapsed_time );
>
> return $elapsed_time;
> }
>
>  // Usage example
> $time_in  = "2000-06-14 06:30:00";
> $time_out = "2000-12-22 13:45:00";
> // Full use of function.
> echo "Days: ";
> echo get_elapsed_time( $time_in, $time_out, "days", "3" );
> // Use defaults for units and decimal places.
> echo "Seconds: ";
> echo get_elapsed_time( $time_in, $time_out );
> ?>
>
> --
> Steve Werby
> COO
> 24-7 Computer Services, LLC
> Tel: 804.817.2470
> http://www.247computing.com/
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


Rick Widmer
Internet Marketing Specialists
http://www.developersdesk.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Time problem

2001-02-07 Thread Steve Werby

"Roman" <[EMAIL PROTECTED]> wrote:
> I have one problem with mysql database. In table i have 2 arrays with time
> format.
> For example this arrays calls IN and OUT. In php script i want to have
> distinction between
> this arrays. For example IN is 8:30:45 and OUT is 16:45:15 and result
> will be: 8:14:30. Exists any function which do this. Tnanx.

If your MySQL fields are a datetime type (-MM-DD hh:mm:ss) then you can
convert them to seconds since epoch (Jan 1, 1970 at midnight) and then
calculate the difference and divide by a number to get appropriate units.
Below is a set of functions I wrote to do that.  Before I get to that here's
a simpler solution:

// $time = "16:45:15";
$time_array = explode( ":", $time);
// $time[0] = 16, $time[1] = 45, $time[2] = 15
$time_since_midnight = $time[0] * 3600 + $time[1] * 60 + $time[2];
// Do this conversion for both times, subtract and convert units.

function get_mysql_to_epoch( $date )
{
list( $year, $month, $day, $hour, $minute, $second ) = split(
"([^0-9])", $date );
return date( "U", mktime( $hour, $minute, $second, $month, $day,
$year ) );
}

function get_elapsed_time( $time_start, $time_end, $units = "seconds",
$decimals = "2" )
{
$divider[years]   = ( 60 * 60 * 24 * 365 );
$divider[months]  = ( 60 * 60 * 24 * 365 / 12 );
$divider[weeks]   = ( 60 * 60 * 24 / 7 );
$divider[days]= ( 60 * 60 * 24 );
$divider[hours]   = ( 60 * 60 );
$divider[minutes] = ( 60 );
$divider[seconds] = 1;

$elapsed_time = ( ( get_mysql_to_epoch( $time_end ) -
get_mysql_to_epoch( $time_start ) )
  / $divider[$units] );
$elapsed_time = sprintf( "%0.{$decimals}f", $elapsed_time );

return $elapsed_time;
}

Days: ";
echo get_elapsed_time( $time_in, $time_out, "days", "3" );
// Use defaults for units and decimal places.
echo "Seconds: ";
echo get_elapsed_time( $time_in, $time_out );
?>

--
Steve Werby
COO
24-7 Computer Services, LLC
Tel: 804.817.2470
http://www.247computing.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Time problem

2001-02-06 Thread Roman

Hello !!


I have one problem with mysql database. In table i have 2 arrays with time
format.
For example this arrays calls IN and OUT. In php script i want to have
distinction between
this arrays. For example IN is 8:30:45 and OUT is 16:45:15 and result
will be: 8:14:30. Exists any function which do this. Tnanx.


Roman





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]