Forum Moderators: coopster

Message Too Old, No Replies

mktime() problem

         

Sarah Atkinson

6:04 pm on Jun 14, 2005 (gmt 0)

10+ Year Member



$e_when is my time formated in the time mktime takes(08,00,00,09,20,2004)but this doesn't return the time?

$e_when2= mktime($e_when);

is it taking $e_when as the first veriable passed and leaving all the others empty? (that's what I think it is doing) How can I get it to grab it as the multiple parramiters? do i have to split the string up into an array then pass each one or is there a function to do this?

Sarah

Sarah Atkinson

6:14 pm on Jun 14, 2005 (gmt 0)

10+ Year Member



this is what I came up with:

$e_when=$row["event_time"];
$ewa=explode(",",$e_when);
$e_whenU= mktime($ewa[0],$ewa[1],$ewa[2],$ewa[3],$ewa[4],$ewa[5]);
$dayheader=date("l, F j, Y", $e_whenU);
$time=date("g:i A", $e_whenU);

But there has to be a better way.

mincklerstraat

9:37 am on Jun 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This looks, at a quick glance, good to me. If it works I don't think you should spend time worrying about a "better way." Date functions are typically complicated since there are so many different ways of textually expressing time and dates. The simplest is what you got from mktime(), which is a unix timestamp, meaning the number of seconds since Jan 1, 1970. This is often the easiest number to use when calculating information based on dates. You just want to transform this information into more human-readable information for your users when you have a result.