Reply LinkBack Thread Tools Search this Thread
Old 11-04-2003, 05:04   #1 (permalink)
smallbeer
I Ain't Losing Any Sleep™
 
Join Date: Apr 2003
Posts: 5,236
php/sql - Making sure value of $time is GMT

I'm just starting out in php so this might be really simple.

I have this bit of php/SQL

Code:
$sql="INSERT into minddump(time,name,email,url,story) VALUES (now(),'$name','$email','$url','$story')";

Instead of giving $time the value of now(), how do I make sure it's GMT?

TIA

Jamie
__________________
That's fuckin' ingenious, if I understand it correctly. It's a Swiss fuckin' watch.
  Reply With Quote
Old 11-04-2003, 11:55   #2 (permalink)
Luke Redpath
Barney army!
 
Luke Redpath's Avatar
 
Join Date: Mar 2003
Location: London
Posts: 696
ASP is my thing, but I would imagine there is a PHP equivalent - if I wanted to be certain my time was displayed in GMT, I'd explicitly set the Locale ID at the top of the page for the UK, overiding the server, but if you know your server ID is set to the UK you shouldn't need to do this:

<%@LANGUAGE="VBScript", LCID=2057%>
__________________
Luke Redpath .::. Software Engineer .::. Reevoo - Real Reviews From Real Customers
  Reply With Quote
Old 12-04-2003, 04:55   #3 (permalink)
smallbeer
I Ain't Losing Any Sleep™
 
Join Date: Apr 2003
Posts: 5,236
Whe I use now() the time is coming up as 5 hours behind so I guess the server is on the east coast of america.

I'll look into the php equivalent of your suggestion.

Cheers Luke.

Jamie
__________________
That's fuckin' ingenious, if I understand it correctly. It's a Swiss fuckin' watch.
  Reply With Quote
Old 12-04-2003, 08:33   #4 (permalink)
Stickman
Dr. Lucien Sanchez
 
Stickman's Avatar
 
Join Date: Mar 2003
Location: UK
Posts: 5,632
This might be no help at all as I don't know php, but when I last used it I had to make changes to the date/time and figured it out with these pages:

http://www.php.net/manual/en/function.time.php

http://www.php.net/manual/en/function.date.php

Hope that helps you somehow
  Reply With Quote
Old 12-04-2003, 10:59   #5 (permalink)
smallbeer
I Ain't Losing Any Sleep™
 
Join Date: Apr 2003
Posts: 5,236
I found this which I think is the equivalent to Luke's suggestion.

Code:
setlocale(LC_TIME,"en_UK");

I think I've played around so much with it though that I've changed something I shouldn't have! Now the date and time are just coming up as 0000-00-00 00:00:00!

I'm gonna leave it for now and come back later. I'd end up clubbing the monitor if I don't! :smash:
__________________
That's fuckin' ingenious, if I understand it correctly. It's a Swiss fuckin' watch.
  Reply With Quote
Old 12-08-2003, 19:13   #6 (permalink)
Sharif
Registered User
 
Join Date: May 2003
Posts: 53
What exactly are you trying to do... I might have a solution for your dillema
  Reply With Quote
Old 13-08-2003, 04:24   #7 (permalink)
smallbeer
I Ain't Losing Any Sleep™
 
Join Date: Apr 2003
Posts: 5,236
I was trying to do it back in April but never found an answer so...

When now() is stored in the database it's the server time, not GMT. The server is in the US -5 hours behind the UK so I want to either store the time in the database as now() +5hours or display it as Time + 5hours. The former would be preferable.
__________________
That's fuckin' ingenious, if I understand it correctly. It's a Swiss fuckin' watch.
  Reply With Quote
Old 13-08-2003, 12:17   #8 (permalink)
Sharif
Registered User
 
Join Date: May 2003
Posts: 53
You can try the following code, just a matter of mixing functions:

adddate(now(),interval <number of hours> hour)

Just replace <number of hours> with whatever you want, in this case 5.
  Reply With Quote
Old 14-08-2003, 03:42   #9 (permalink)
smallbeer
I Ain't Losing Any Sleep™
 
Join Date: Apr 2003
Posts: 5,236
Cheers, I'll try it out next time I need it.
__________________
That's fuckin' ingenious, if I understand it correctly. It's a Swiss fuckin' watch.
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8