Re: [PHP] Need help with formatting time

2001-07-17 Thread Jason Bell

try looking here:
http://www.php.net/manual/en/function.mktime.php

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

-JB


- Original Message - 
From: John Holcomb [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Tuesday, July 17, 2001 12:53 PM
Subject: [PHP] Need help with formatting time


 Hello and thank you.
 
   I'm trying to find a function(method) or existing
 code taht takes the number of minutes that have passed
 in a day and returns the time of the day.  For
 example:
 
  780 minutes == 1pm,
  0 minutes == 12am,
  etc,etc.
 
 so I'm looking for code that when you enter the number
 of minutes, it returns the time of day.
 
 example:   
  
 $some_time = foo(780);
 
 print($some_time);
 
file://prints 1:00pm
 
 
 Thnaks again.
 
 __
 Do You Yahoo!?
 Get personalized email addresses from Yahoo! Mail
 http://personal.mail.yahoo.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 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] Need help with formatting time

2001-07-17 Thread Christopher Ostmo

John Holcomb pressed the little lettered thingies in this order...

 Hello and thank you.
 
   I'm trying to find a function(method) or existing
 code taht takes the number of minutes that have passed
 in a day and returns the time of the day.  For
 example:
 
  780 minutes == 1pm,
  0 minutes == 12am,
  etc,etc.
 
 so I'm looking for code that when you enter the number
 of minutes, it returns the time of day.
 
 example:   
 
 $some_time = foo(780);
 
 print($some_time);
 
//prints 1:00pm
 
 
 Thnaks again.
 

$minutes = 780;

$some_time = date(g:i a,mktime(0,$minutes,0,01,01,2000));
echo $some_time;

The combination of date() and mktime() can do just about anything with 
dates and times that you could ever possibly dream of doing (it can 
even do some nifty stuff with english ordinal suffixes that have nothing to 
do with dates or time).

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

Christopher Ostmo
a.k.a. [EMAIL PROTECTED]
AppIdeas.com
Innovative Application Ideas
Meeting cutting edge dynamic
web site needs since the 
dawn of Internet time (1995)

Business Applications:
http://www.AppIdeas.com/

Open Source Applications:
http://open.AppIdeas.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] Need help with formatting time

2001-07-17 Thread Rasmus Lerdorf

That's rather simple:

   echo date(H:i:s,mktime(0,$minutes,0));

-Rasmus

On Tue, 17 Jul 2001, John Holcomb wrote:

 Hello and thank you.

   I'm trying to find a function(method) or existing
 code taht takes the number of minutes that have passed
 in a day and returns the time of the day.  For
 example:

  780 minutes == 1pm,
  0 minutes == 12am,
  etc,etc.

 so I'm looking for code that when you enter the number
 of minutes, it returns the time of day.

 example:

 $some_time = foo(780);

 print($some_time);

//prints 1:00pm


 Thnaks again.

 __
 Do You Yahoo!?
 Get personalized email addresses from Yahoo! Mail
 http://personal.mail.yahoo.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] Need help with formatting time

2001-07-17 Thread Christopher Ostmo

Jack Dempsey pressed the little lettered thingies in this order...

 $hours = $time / 60;
 $minutes = $time % 60;
 
 if($hours = 12){
  $meridian = 'pm';
  $hours -= 12;
 }
 else{$meridian = 'am';}
 if($hours == 0){$hour = '12';}
 
 echo $hours:$minutes$meridian;
 
 try something like that...haven't tested it, but it should be close...
 

That's a lot of code!

Use date() and mktime() and PHP will do all of this for you in one line.  
See my previous post on the subject. I sent *tested* code that will fit on 
a single line and will do exactly what the above is doing.

Christopher Ostmo
a.k.a. [EMAIL PROTECTED]
AppIdeas.com
Innovative Application Ideas
Meeting cutting edge dynamic
web site needs since the 
dawn of Internet time (1995)

Business Applications:
http://www.AppIdeas.com/

Open Source Applications:
http://open.AppIdeas.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] Need help with formatting time

2001-07-17 Thread scott [gts]

This will convert minutes to hours, then convert
to 12-hour am|pm based time.   all hours have 60
minutes.  it's simple mathematics to convert.

$m = 780;
$h = 0;

// convert to hours:minutes
while ($m = 60) {
  $h++;
  $m -= 60;
}
print $h:$m \n;

// convert to 12-hour am|pm 
if (!$h) {
  $suff = am;
  $h = 12;
}
elseif ($h == 12) {
  $suff = pm;
}
elseif ($h  12) {
  $suff = pm;
  $h -= 12;
}
print $h:$m $suff;

 -Original Message-
 From: John Holcomb [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, July 17, 2001 3:53 PM
 To: [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Subject: [PHP] Need help with formatting time
 
 
 Hello and thank you.
 
   I'm trying to find a function(method) or existing
 code taht takes the number of minutes that have passed
 in a day and returns the time of the day.  For
 example:
 
  780 minutes == 1pm,
  0 minutes == 12am,
  etc,etc.
 
 so I'm looking for code that when you enter the number
 of minutes, it returns the time of day.
 
 example:   
  
 $some_time = foo(780);
 
 print($some_time);
 
//prints 1:00pm
 
 
 Thnaks again.
 
 __
 Do You Yahoo!?
 Get personalized email addresses from Yahoo! Mail
 http://personal.mail.yahoo.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 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] Need help with formatting time

2001-07-17 Thread Jack Dempsey

Once again, a reminder of the smartest way to code php:
1) think for 2 seconds
2) check out php.net for documentation on functions
3) use a function (or 2) already written instead of spending time
yourself...

jack

-Original Message-
From: Christopher Ostmo [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, July 17, 2001 5:11 PM
To: Jack Dempsey
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP] Need help with formatting time

Jack Dempsey pressed the little lettered thingies in this order...

 $hours = $time / 60;
 $minutes = $time % 60;
 
 if($hours = 12){
  $meridian = 'pm';
  $hours -= 12;
 }
 else{$meridian = 'am';}
 if($hours == 0){$hour = '12';}
 
 echo $hours:$minutes$meridian;
 
 try something like that...haven't tested it, but it should be close...
 

That's a lot of code!

Use date() and mktime() and PHP will do all of this for you in one line.

See my previous post on the subject. I sent *tested* code that will fit
on 
a single line and will do exactly what the above is doing.

Christopher Ostmo
a.k.a. [EMAIL PROTECTED]
AppIdeas.com
Innovative Application Ideas
Meeting cutting edge dynamic
web site needs since the 
dawn of Internet time (1995)

Business Applications:
http://www.AppIdeas.com/

Open Source Applications:
http://open.AppIdeas.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 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]