Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GMT Time

Status
Not open for further replies.

DonP

IS-IT--Management
Jul 20, 2000
684
US
I'm using [tt]time()[/tt] to insert the current date and time into a MySQL table but as far as I can tell, this is local time. What is the correct syntax for making it use the current GMT time? Don
don@pc-homepage.com
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT/2000 (only when I have to!)
 
That was fast! Actually, I tried both date() and gmdate() before posting but each seems to require parameters. I am trying to write the time as Epoch time with just integers and no date formatting whatsoever. Any other ideas? Don
don@pc-homepage.com
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT/2000 (only when I have to!)
 
By trail and error, I think I got it. I need [tt]gmmktime()[/tt] which seems to work. Don
don@pc-homepage.com
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT/2000 (only when I have to!)
 
in your query you can do this:

insert into date-timefield date_add(now(),interval <offset to local> hour);

offset to local is positive, use date_sub for negative. if you'd rather use minutes do that instead. ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Thanks, but the [tt]now()[/tt]is not what I needed in this instance. I can't actually easily modify the insert statement itself (the script was generated by an IDE program) so things like this need to be done using other methods but in the script that presents the info, I am making it appear as local time so the end results are the same. At any rate, having it write to GMT is what I need and it's working perfectly now with [tt]gmmktime()[/tt]. Thanks again. Don
don@pc-homepage.com
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT/2000 (only when I have to!)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top