stefan63 Posted January 29, 2009 Share Posted January 29, 2009 Hello, i have an reverse auctionscript (German) and it displays the date wrong. Following problem: When i change the (d.m.Y) to (d.M.Y) in the config.inc then when i post an auction more then 4 days it will appear 31.Dec.1969 in the "Auction End time" ($endet) the posted date is 28.Jan.2009. But when i change it to (d.m.Y) everything is ok only that it shows German Date like 28.01.2009 and thats not good here in US. When i post an auction less than 4 or 4 days everything looks fine and the auction ends properly. I changed all the $endet (d.m.Y) to (d.M.Y) and so far was everything fine till i tried to post an auction more than 4 days ( 5 or up to 60 days). I appreciate any help, i went thru the PHP.net and searched all the date and time formats . i can't find out what i'm doing wrong. ??? Thanks Stefan below the code from config.inc ///config.inc.php ///Zeitmodul $sommerzeit = "0"; $monate = array("01.","02.","03.","04.","05.","06.","07.","08.","09.","10.","11.","12."); list($wday,$tage,$monatzahl,$jahr) = split("( )",date("w j n Y")); $monatzahl -= 1; $startzeit = date ("d.m.Y", mktime(0,0,0,$monate[$monatzahl],($tage),$jahr)); if (!isset($stringDate)) $stringDate = "H:i:s"; if (isset($sommerzeit)) $uhrzeit = date($stringDate, time()+$sommerzeit*3600); else $uhrzeit = date($stringDate, time()+0*3600); $time = $uhrzeit; $zeitstart=time(); and here the code from the other template pages: (just the date/time code) //////Endzeit darstellen $grundzeit="86400"; $xxxx = ($endzeit/$grundzeit); $suchedat = explode (".", $startdatum); if ($suchedat[0]+$xxxx > "31") { $newdat=$suchedat[1]; $endet = date ("d.M.Y", mktime(0,0,0,$newdat,($startdatum+$xxxx),$suchedat[2])); } else { $endet = date ("d.M.Y", mktime(0,0,0,$monate[$monatzahl],($startdatum+$xxxx),$suchedat[2])); } //////ENDE Endzeit darstellen ///////////////////////////// $end1a = explode (".", $endet); $end1b = explode (":", $startuhr); $aktuell1a = explode (".", $startzeit); $aktuell1b = explode (":", $uhrzeit); if ($end1b[2]== "") { $end1b[2]="00"; } $zeitstar=$zeitstart-$endzeit; $differ=$ipnr-$zeitstar; $stringDate2 = "H:i:s"; $enduhrzeit=date($stringDate2, $differ); $endlaufzeit = explode (":", $enduhrzeit); $Diff = (Integer) (($ipnr+$endzeit - $zeitstart) / 3600 / 24); if ($endlaufzeit[0]<= "0") { $endlaufzeit[0]="23"; } else { $endlaufzeit[0]=$endlaufzeit[0]+5; } ////////////////////////////////////////// Quote Link to comment https://forums.phpfreaks.com/topic/142893-solved-problems-with-date-and-time-please-help/ Share on other sites More sharing options...
MadTechie Posted January 29, 2009 Share Posted January 29, 2009 okay where is $startdatum being set ? and is $end1a being used anywhere else ? the problem is likely due to the fact the script uses explode on the dates eg $suchedat = explode (".", $startdatum); $newdat=$suchedat[1]; //hence this would be Jan instead of 01 Quote Link to comment https://forums.phpfreaks.com/topic/142893-solved-problems-with-date-and-time-please-help/#findComment-749188 Share on other sites More sharing options...
stefan63 Posted January 29, 2009 Author Share Posted January 29, 2009 Thanx for your respond, ok.... $startdatum is being used on the auction site and in several emails to the admin and user. eg. register and auction end emails. For example: Posted on: $startdatum Ends on: $endet Servertime: $today i'm not sure about $end1a or $end1b . There used to be a countdown on the auction sites but i deleted that specific area in the html but this code is still there. I think it belongs to the countdown? i'm not sure. Quote Link to comment https://forums.phpfreaks.com/topic/142893-solved-problems-with-date-and-time-please-help/#findComment-749228 Share on other sites More sharing options...
CG_dude Posted January 29, 2009 Share Posted January 29, 2009 This script works great for me, just be sure to edit your time zone <SCRIPT TYPE="text/javascript"> <!-- Begin // Get today's current date. var now = new Date(); // Array list of days. var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); // Array list of months. var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December'); // Calculate the number of the current day in the week. var date = ((now.getDate()<10) ? "0" : "")+ now.getDate(); // Calculate four digit year. function fourdigits(number) { return (number < 1000) ? number + 1900 : number; } // Join it all together today = days[now.getDay()] + ", " + months[now.getMonth()] + " " + date + ", " + (fourdigits(now.getYear())) ; // Print out the data. document.write(today); // End --> </script> <SCRIPT Language="JavaScript"> <!-- hide from old browsers var TimezoneOffset = -8 // adjust for time zone var localTime = new Date() var ms = localTime.getTime() + (localTime.getTimezoneOffset() * 60000) + TimezoneOffset * 3600000 var time = new Date(ms) var hour = time.getHours() var minute = time.getMinutes() var second = time.getSeconds() var curTime = "" + ((hour > 12) ? hour - 12 : hour) if(hour==0) curTime = "12" curTime += ((minute < 10) ? ":0" : ":") + minute curTime += ((second < 10) ? ":0" : ":") + second curTime += (hour >= 12) ? " PM" : " AM" document.write(curTime + " US Pacific Time") //--> </SCRIPT> Quote Link to comment https://forums.phpfreaks.com/topic/142893-solved-problems-with-date-and-time-please-help/#findComment-749243 Share on other sites More sharing options...
stefan63 Posted January 29, 2009 Author Share Posted January 29, 2009 CG_dude ok but does the date ($startdatum in english $startdate) stay the same date till the auction ends or does it change evry day to the actual date (today) ? I'm relatively new to PHP , where do i have to put the $startdatum in the code you posted? and do i have to change all template sites or only the index.php ? thank you Stefan Quote Link to comment https://forums.phpfreaks.com/topic/142893-solved-problems-with-date-and-time-please-help/#findComment-749253 Share on other sites More sharing options...
stefan63 Posted January 29, 2009 Author Share Posted January 29, 2009 The code you posted is the same i have in my header.php to show actual servertime. If i use this code the posted on date will change every day to the actual date (today) I need a date which stays the same till auction end. Like here in the Forum the date shows when you registered for example. When somebody posts an auction then it shows : posted on and ends on . My problem is that when i change the (d.m.Y) in the config for the startdate then the enddate shows 31.Dec.1969 . when i change it to (d.m.Y) then the enddate shows the right enddate but the startdate looks like German date eg. 29.01.2009 . thanks for any reply or ideas Stefan Quote Link to comment https://forums.phpfreaks.com/topic/142893-solved-problems-with-date-and-time-please-help/#findComment-749608 Share on other sites More sharing options...
stefan63 Posted January 30, 2009 Author Share Posted January 30, 2009 Thanks very much Another Forum which does'nt support Newbees. Why don't the programmers just lock the fu.... forums and don't let anybody who does'nt know as much register? Just to tell ya all what a simple piece of code is....i found it out by myself....and NO..i did'nt google...i bought me a book. All that ya'll here in the forums do is link to other forums or sites. ///////////////////// function date_time($timestamp) { return date("M.d.Y, $timestamp"); } $endtime=date_time($ipnr+$endzeit); /////////////////////// thats all i was lookin for...smart asses Quote Link to comment https://forums.phpfreaks.com/topic/142893-solved-problems-with-date-and-time-please-help/#findComment-750389 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.