You are here: Re: time to int function. « All PHP « IT news, forums, messages
Re: time to int function.

Posted by Hans 'pritaeas' Pollaerts on 07/19/06 15:21

Error: line 1 must be:

$time = date ("H:i", time ());

Here's a more complete test:

<?php
function getMinutes ($time) {
$time = date ("H:i", $time);
sscanf ($time, "%d:%d", $hours, $minutes);
return ($hours * 60) + $minutes;
}

$time = mktime (1, 30);
echo $time;
echo "<br>";
echo date ("H:i", $time);
echo "<br>";
echo getMinutes ($time);
?>


"Hans 'pritaeas' Pollaerts" <pritaeas@hotmail.com> wrote in message
news:e9li0g$r8n$1@news6.zwoll1.ov.home.nl...
> Try this, you can create a function from it:
>
> <?php
> $time = date ("H:m", time ());
> echo $time . " => ";
> sscanf ($time, "%d:%d", $hours, $minutes);
> echo ($hours * 60) + $minutes . " minutes";
> ?>
>
> "PSI_Orion" <orion@psiss.com> wrote in message
> news:WXpvg.494$t4.298@newsfe3-win.ntli.net...
> > Is there a simple function that returns HH:MM to an actual integer? In
> > other words, would convert 1:30 to 90, 2:00 to 120, 4:00 to 240, 1:56 to
> 116
> > etc. or is this something you have to create a function for?
> >
> > I've looked at all the date and time functions but for the life of me, I
> > can't find which one it is I need to use.
> >
> > Regards
> >
> > PSI_Orion
> >
> >
>
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация