Jump to content
rootKID

Help with time echo...

Recommended Posts

yoyo w3...a little help would be awsome!... im trying to make my own little time shower in the top of my website... the only problem is that the codes does not work... i founded it on a open-source forum kinda... almost like this, just alot of hardcore coders, i suppose... anyways...here is my codes:

function mkprettytime($s) {    if ($s < 0)	    $s = 0;    $t = array();    foreach (array("60:sec","60:min","24:hour","0:day") as $x) {	    $y = explode(":", $x);	    if ($y[0] > 1) {		    $v = $s % $y[0];		    $s = floor($s / $y[0]);	    }	    else		    $v = $s;	    $t[$y[1]] = $v;    }    if ($t["day"])	    return $t["day"] . "d " . sprintf("%02d:%02d:%02d", $t["hour"], $t["min"], $t["sec"]);    if ($t["hour"])	    return sprintf("%d:%02d:%02d", $t["hour"], $t["min"], $t["sec"]);//    if ($t["min"])	    return sprintf("%d:%02d", $t["min"], $t["sec"]);//    return $t["sec"] . " secs";}function gmtime(){    return strtotime(get_date_time());}function get_dt_num(){  return gmdate("YmdHis");}// Returns the current time in GMT in MySQL compatible format.function get_date_time($timestamp = 0){  if ($timestamp)    return date("Y-m-d H:i:s", $timestamp);  else    return gmdate("Y-m-d H:i:s");}

and what i wish it to look like, would be somfthing like so: Monday - 23.42 - JULY,ECT... but the most important thing for me right now, is that i would like to get this one worked, since i think that it could be awsome to have it with me when i create a fully front-end that should be user-friendly for some :)... Hoping some answers soon, regards... PS: i do not know if somfthing is missing orr like that, but dont think so... i got the following error by calling the function ''mkprettytime''...: Warning: Missing argument 1 for mkprettytime(), called in C:\xampp\htdocs\ss_tracker_2011\status_left.php on line 3 and defined in C:\xampp\htdocs\ss_tracker_2011\include\config.php on line 104 thanks in advance! :)...

Share this post


Link to post
Share on other sites

it doesn't look like you gave us all your code. Please provide all relevant code when you post. If you look at the error message, it says that mkprettytime it is expecting one argument to be passed in, which you can confirm by reading the function signature

function mkprettytime($s) {

somewhere in config.php, you are calling mkprettytime without passing the expected argument.

Share this post


Link to post
Share on other sites

ah yes I meant to say, as JSG added, most of what that code does is superflous given what date formatting is naturally built into PHP.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...