Forums

Wrong timestamp in database

ProEventMedia 28 Nov, 2008
I need to set the recordtime +7 hours for my form submissions since I'm in another timezone than my server. How do I do that?
Max_admin 28 Nov, 2008
Hi, edit the Autogenerated code, there is a date( ) function used there, edit it to add +7 hours, you may use google quickly to look how to add some time difference to the "date()" function in PHP

Regards
Max

P.S: if you couldn't do it then please post back and I will look for this!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ProEventMedia 29 Nov, 2008
Thank you for your quick answer, but I'm not so PHP savvy... I need help how to modify the code. Here is the first lines with date():
srand((double)microtime()*10000);
	$inum	=	"I" . substr(base64_encode(md5(rand())), 0, 16);

$database->setQuery( "INSERT INTO #__chronoforms_3 VALUES  (
'' , '".$inum."','". date('Y-m-d')." - ".date("H:i:s")."', '".$_SERVER['REMOTE_ADDR']."' , '".mosGetParam($_POST,'formfield1','')."' , 

I've looked at this page: http://se2.php.net/date but I don't know how to make use of anything there...
Max_admin 30 Nov, 2008
Hi, see this code from PHP site:

$nextWeek = time() + (7 * 24 * 60 * 60);                   // 7 days; 24 hours; 60 mins; 60secs
echo 'Now:       '. date('Y-m-d') ."\n";
echo 'Next Week: '. date('Y-m-d', $nextWeek) ."\n";// or using strtotime():
echo 'Next Week: '. date('Y-m-d', strtotime('+1 week')) ."\n";


you can edit it alittle to add only estra 7 hours, let me know if you couldn't achieve it!๐Ÿ™‚

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ProEventMedia 30 Nov, 2008
Ok, I changed tha date part of the code to this:

". date('Y-m-d', strtotime('+7 hours'))." - ".date("H:i:s", strtotime('+7 hours'))."


and time is now displayed correctly but I don't know if this works with the date? Will it show the right date when it's past midnight here but before midnight server time? I'll have to stay up late and check that tonight๐Ÿ™‚
GreyHead 30 Nov, 2008
Hi ProEventMedia,

Yes it should to that correctly, the whole timestamp is set to 7 hours ahead/back!

Bob
Max_admin 30 Nov, 2008
I agree with Bob, let us know after you test!

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ProEventMedia 30 Nov, 2008
Nice, It works! Server time (in USA) was 2008-11-30 - 17:55:46 but my recorded local time (in Sweden) was 2008-12-01 - 00:55:46 = + 7 hours with different date!
PERFECT!๐Ÿ˜€ Thank you for all your help.
GreyHead 01 Dec, 2008
Hi ProEventMedia,

Glad this worked for you. You may have some small problems though in the periods when Daylight Savings Time changes as the USA and Europe are out of sync for a few weeks in the spring and autumn. This probably isn't a practical problem but better to be aware of it.

Bob
MattPelatan 29 Sep, 2011
Hi,

I've the same problem but I don't know where I can find the autogenerated code. Could you help me?
Thanks

Matt

Hi, edit the Autogenerated code, there is a date( ) function used there, edit it to add +7 hours, you may use google quickly to look how to add some time difference to the "date()" function in PHP

This topic is locked and no more replies can be posted.