TheUnknown Posted September 19, 2008 Share Posted September 19, 2008 mktime() expects parameter 1 to be long, string given in /home/home/public_html/storage/lib/stdlib.php on line 200 line 200 is return date("m/d/Y", mktime($hr,$mi,0,$mo,$da,$yr)); any ideas on whats going on here? Link to comment https://forums.phpfreaks.com/topic/125019-mktime-error/ Share on other sites More sharing options...
F1Fan Posted September 19, 2008 Share Posted September 19, 2008 Don't know what your $hr, $mi, $mo, $da, and $yr vars are. Personally, I prefer strtotime. <?php return date("m/d/Y", strtotime("$yr-$mo-$da $hr:$mi:00")); ?> Link to comment https://forums.phpfreaks.com/topic/125019-mktime-error/#findComment-646030 Share on other sites More sharing options...
TheUnknown Posted September 19, 2008 Author Share Posted September 19, 2008 $yr = strval(substr($dt,0,4)); $mo = strval(substr($dt,4,2)); $da = strval(substr($dt,6,2)); $hr = strval(substr($dt,8,2)); $mi = strval(substr($dt,10,2)); Thanks for the response Link to comment https://forums.phpfreaks.com/topic/125019-mktime-error/#findComment-646036 Share on other sites More sharing options...
F1Fan Posted September 19, 2008 Share Posted September 19, 2008 What format is $dt? You might be able to just do this: <?php return date("m/d/Y", strtotime($dt)); ?> Link to comment https://forums.phpfreaks.com/topic/125019-mktime-error/#findComment-646037 Share on other sites More sharing options...
TheUnknown Posted September 19, 2008 Author Share Posted September 19, 2008 Yo F1 Heres all the code function mysql_timestamp($dt, $blank="") { /* returns formatted MySQL timestamp, or $blank if it's blank */ if (empty($dt)) return $blank; $yr = strval(substr($dt,0,4)); $mo = strval(substr($dt,4,2)); $da = strval(substr($dt,6,2)); $hr = strval(substr($dt,8,2)); $mi = strval(substr($dt,10,2)); return date("m/d/Y", strtotime($hr,$mi,0,$mo,$da,$yr)); } Link to comment https://forums.phpfreaks.com/topic/125019-mktime-error/#findComment-646039 Share on other sites More sharing options...
F1Fan Posted September 19, 2008 Share Posted September 19, 2008 Right, but in what format is $dt coming in as?? List an example, like: 2008-09-19 10:47 AM or whatever... Link to comment https://forums.phpfreaks.com/topic/125019-mktime-error/#findComment-646041 Share on other sites More sharing options...
TheUnknown Posted September 19, 2008 Author Share Posted September 19, 2008 2008-09-19 19:18:25 Link to comment https://forums.phpfreaks.com/topic/125019-mktime-error/#findComment-646043 Share on other sites More sharing options...
F1Fan Posted September 19, 2008 Share Posted September 19, 2008 OK, perfect. Just use that last example I listed and make your function look like this: <?php function mysql_timestamp($dt, $blank="") { /* returns formatted MySQL timestamp, or $blank if it's blank */ if (empty($dt)) return $blank; return date("m/d/Y", strtotime($dt)); } ?> Link to comment https://forums.phpfreaks.com/topic/125019-mktime-error/#findComment-646045 Share on other sites More sharing options...
TheUnknown Posted September 19, 2008 Author Share Posted September 19, 2008 Ok good i will use your code I do wonder why im getting this error tho? I mean it works and if i never loaded my logs i wouldn't have had any idea that something was wrong Link to comment https://forums.phpfreaks.com/topic/125019-mktime-error/#findComment-646048 Share on other sites More sharing options...
F1Fan Posted September 20, 2008 Share Posted September 20, 2008 That's more of a notification than an error. A real error will kill your program. Link to comment https://forums.phpfreaks.com/topic/125019-mktime-error/#findComment-646083 Share on other sites More sharing options...
Zane Posted September 20, 2008 Share Posted September 20, 2008 instead of strval......use intval $yr = strval(substr($dt,0,4)); $mo = strval(substr($dt,4,2)); $da = strval(substr($dt,6,2)); $hr = strval(substr($dt,8,2)); $mi = strval(substr($dt,10,2)); that's too much work. try this script instead $yr = date("Y", strtotme($dt)); $mo = date("m", strtotme($dt)); $da = date("d", strtotme($dt)); $hr = date("G", strtotme($dt)); $mi = date("i", strtotme($dt)); Link to comment https://forums.phpfreaks.com/topic/125019-mktime-error/#findComment-646106 Share on other sites More sharing options...
DarkWater Posted September 20, 2008 Share Posted September 20, 2008 You left out the 'i' in 'time' all 5 times that you types that. I'll assume you copypasta'd it. Link to comment https://forums.phpfreaks.com/topic/125019-mktime-error/#findComment-646113 Share on other sites More sharing options...
Zane Posted September 20, 2008 Share Posted September 20, 2008 I mispelled it, but yeah I "copypasta'd" it thanks for spotting that $yr = date("Y", strtotime($dt)); $mo = date("m", strtotime($dt)); $da = date("d", strtotime($dt)); $hr = date("G", strtotime($dt)); $mi = date("i", strtotime($dt)); Link to comment https://forums.phpfreaks.com/topic/125019-mktime-error/#findComment-646114 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.