Php Server Time

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > PHP Programming

Php Server Time

BOAW
i think i may asked this question awhile back but i never really got it solved. ok..i had a block that told me the server time info or whatever. and the GMT wus at 00:00 i wanted to change it to -5:00 but i didnt know how, so how can i change it? im not sure of the codes in the php to change it to the right GMT time becuase im always gettn the wrong times n day

Reply

juice
I have the same problem. The server I am using is five hours behind my local time and I don't know how to change it. But I have a solution - just leave it at the time it is laugh.gif

Reply

jlhaslip
It is usually neccesary to adjust the time whenever you use a php time function since it is common to have the server time set to GMT.
A typical php code to do that would be something like this:
CODE

$offset_from_server_time = -6; // a variable defined in the head of the page
.
. more code here
.
$my_time = time() + ( 60 * 60 * $offset_from_server_time );
.
. more code here
.


See also:

http://www.trap17.com/forums/index.php?sho...mp;#entry285204

Reply

peroim
it isn't hard or so. you just take the servertime and 'add' -5 hours. and since time() gives seconds, that will be -5*60*60 seconds. so here's an example script:

CODE

<?php
$timezone = -5;
//rather clear, this is your timezone (in hours) (real timezone)

$here = time() + $timezone*60*60;
//the time in your timezone, long number, so not good for output;)

echo gmdate("l j F Y, h:i A", $here);
//echo some time
?>


gmdate() is exactly the same as date(), but it uses greenwich time, and not servertime. (If using an input time in UNIX-format.)

Cya, Peroim

Reply

electron
Well your script would give you the time double ahead of the GMT time because you guys are subtracting first and then using gmdate.

GMDATE() function requires the current time as per the server.
Then accordingly it will find what are the server settings and convert the time and then give the GMT time.

So your script is now:

CODE
gmdate("M d Y H:i:s", mktime())


This is the GMT time as per the server.
However if you make a server change the time would go wrong as gmdate takes the servers time settings.
But on the same server it is just fine.

Hope that helps.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. cpanel adjust server time - 272.22 hr back. (1)
  2. how to change servertime in xampp - 495.44 hr back. (1)
  3. change .htaccess servertime cpanel - 586.15 hr back. (1)
Similar Topics

Keywords : php, server, time

  1. Google Going Back In Time
    (5)
  2. Help With Compiling My Server
    I can't compile it. IMPORTANT!! :( (0)
    Okay, so I downloaded JDK6.0 UPDATE 7, just like the tutorial said. Now every time I go to compile,
    it says I am missing JDK! If someone could help me out, and if they are interested in become the
    Head Mod of my private server, I have no problem with giving them those rights. I already made the
    compiler but when I open it, and type "C" it won't compile because it says I don't have JDK
    when I do. After I compile, I will run the server, then add some NPCs and change some stuff around,
    and it will be complete! /smile.gif" style="vertical-align:middle" emoid....
  3. Windows Xp Sp2 Restarting After Some Time
    (5)
    Hi , I dont know what happened but My system restarts after a few Minutes (at max an hour). Can
    someone guess what might be wrong. It displays a System Shutdown Timer (initiated by
    Administrator) and then restarts after 60 sec. This is an SP2 so I dont think its a blaster. I
    have a ZoneAlarm Security Suite and it didn't detect anything. I even Scanned my Windows folder
    from Kaspersky using my Second OS (Vista) but that also didn't detect anything . .. Any guesses
    ??....
  4. The Other Hdd Does Not Appear On My Server
    (2)
    I have a primitive Dell POwerEdge2300 that i got from a friend. I remember when he he gave it to me
    5 months ago we ran Windows Server 2003 but when I switched it on yesterday it could not find any
    boot device. After playing around with the hardrives it finally booted with Win2K which I had not
    seen when we ran it the first time. The problem is when I am in BIOS I see both drives but when I
    boot into windows only C:\ appears in Windows Explorer. I can see both drives in the device
    manager and they are said to be working fine how do I access the other drive which I b....
  5. Time Travel - An Impossibility?
    Is time travel possible? Will we ever manage it? What are the dangers? (14)
    Ok, I dont really know anything about the subject. But I just spend a lot of time thinking about
    this kind of thing, so thought i would post my thoughts and ideas, and see what people think. First
    of all; What do people mean by "time travel" Now, i think most people think of traveling back or
    forward in time, and being in a certain place at a certain time, in full body, when they think of
    time travel. But is that possible? But surely time travel could just be seing, history, or future.
    And how would it work? Surely it would involve opening time, and placing yourself, i....
  6. Dohwow
    4 my private server (2)
    how do i add php into the website im so lost ^^ /sad.gif" style="vertical-align:middle" emoid=":("
    border="0" alt="sad.gif" />....
  7. Private Servers
    Private server discussions (16)
    The thing about MMORPG private servers, are that there are too many of them. Ask yourself: "Is it
    worth creating a private server to attract player when there are already thousands out there?" "Is
    it worth creating a private server and getting sued?" "Is it worth it to use up RAM and Internet to
    host one?" "Is it worth it to get hacked?" "Is it worth it competing against other servers knowing
    that they are much better than you?" Is it worth it in the end? I say, it is. When you're
    creating a private server of your own, have a think about these things. ....
  8. Spare Time?
    (5)
    What do you guys do in your spare time, when you are not on the computer or at school/work? For me,
    well, I play sports, like hockey, baseball, and football. I also play 6-7 musical instruments, with
    drums being my favorite. I also plan on learning the bass guitar in the next few years, after I get
    pretty good at the drums, which I am focusing on now. How about you guys?....
  9. The Time Traveller's Wife
    Recommendation (0)
    Audrey Niffenegger is the author of this absolutely brilliant book! Her writting is very
    'real' and the story line is definitely one you have never read before. The Time
    Traveller's Wife is an absolute must for anyone who enjoys reading. The main plot is about a
    guy, Henry, who time travels and basically meets his wife when she is 10 and he is about 40 years
    old! I will not tell you any more so as not to reveal more of the story..... 'HERE'S
    THE NEXT THE LOVELY BONES...A RARE BOOK' -EVENING STANDARD 'At its core The Time
    Traveler'....
  10. Creating A Shortcut List Near The System Tray
    Time saver tip for windows (4)
    Are you bored at work today? Here's a small enhancement to your desktop. Hope you like it. I)
    When you have to open any program you have to click "Start" "All Programs" and then choose your
    selection from the programs folder. Now how would it be to achieve the same task in just two clicks?
    You can save all your favourite program shortcuts in a folder and view that through a tiny arrow
    near the system tray. Its very simple. You would tell, "Ya, I almost knew that". Here's how to
    do it. a) First create your folder and add the shortcuts you want to access. The f....
  11. Private Server
    (1)
    Well Private servers first came into my mind a few years back when i asked someone about "Zezima" a
    High Leveled Runescape Player, he said that "Zezima" Uses a Private "World" Which are Servers that
    are hosted through out the Real World and then connect to a Login/Game Server. now a "Private"
    Server I was wondering what it was and how we may get Access to that, well for one it would have to
    connect to the official Runescape Game Server in order to see the Graphics and Game Details and so
    on, this could not be possible because Runescape has a Web Browser based Client, but....
  12. A Web Server On Lan
    (9)
    Hey friends .. I m new to the forum and would like to ask for help. I have just started writing
    script for web pages. I can make fairly good pages using HTML, PHP and for the backend database I
    use MySQL. I live in a college hostel and my computer is connected to a LAN having about 300
    computers. What I want is to make my web pages available to the LAN users...when I try to do so a
    message appears.. u don't have permission to view on this server. I m doing this just for
    curiosity and fun. I think this would be quit simple.....I don't know much about netw....
  13. Another Cust. Service Rant... This Time As A Customer
    (6)
    On monday I experienced something that I haven't in a long time. Good customer service. I work
    in the line of customer service, and I have come to the conclusion, there are different levels you
    can provide. True customer service is hardly ever given anymore. For example, I ordered from
    McDonalds recently and I ordered a McFlurry and a Sundae. I was given a McFlurry and a Shake. It was
    at the start of a minor busy period (3 or 4 people were behind me waiting to order), so I waited
    until the others were served, and I said to the lady that served me in a polite tone, "I....
  14. Debate With The Religions : Christian Vs Islam Vs More
    This time I don't debate, you do (17)
    So I've done some nice debating and it's been nice. I've had multipe 5+ People ganging
    up on me thinking it will make a real difference, but after pages and pages of debating, it
    didn't go anywhere. Simply because they are afraid to look at it from the other angle, the other
    side, because they fear going to hell. It's their problem. So I made this creative topic. This
    thread is not ment for argueing and fighting. I want to see how you guys feel about each other's
    religion" So muslims, christians, and anything else in between, you have your own....
  15. How To Make Your Own Counter Strike Source Dedicated Server!
    (38)
    Ok, so you want to host your own CSS Server on your computer eh? Well you will not need a lot of
    things, and it is very simple. All you will need is time. /biggrin.gif"
    style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> I did this tutorial
    myself, from my experience when I made my own CSS Server. This is just a simple tutorial! It
    ONLY covers the basics of making a CSS server! Lets Get Started! /laugh.gif"
    style="vertical-align:middle" emoid=":lol:" border="0" alt="laugh.gif" /> 1. Download the HLDS
    Update Tool from here . 2. On....
  16. Budding Java Game Developers?
    Ever wanted to make your own java web-based game, but not had the time (10)
    Right, this is the first post of hopefully many in this thread. Basically the idea is to get many
    developers together to share ideas and knowledge to create our very own game. First we'll be
    asking for is any ideas of what kind of game everybody would like to make, and then we'll set
    about assigning tasks depending on everybodies skills. We will need programmers, artists,
    web-designers, even admin and marketing. This will be freeware, but the experience will be great.
    So, ideas anyone?....
  17. Tutorial On How To Compile Your Own Mangos World Of Warcraft Private Server.
    A great way to learn about how big MMORPGs work and are built. (3)
    ==================== | Disclaimer Please read | ==================== This is an
    educational project ONLY! It is NOT MENT TO BE RAN AS A PUBLIC SERVER! If you do run a
    public server it MAY be against Blizzard's (World of Warcraft's parent company) EULA and you
    will void any agreements including the right to play on their servers. They will DELETE YOUR ACCOUNT
    and possibly ban you from their servers all together. I am writing this to help you learn what goes
    into making a big time MMORPG and possibly get people into learning about video game prod....
  18. Recommended Server-side Programming Language
    (7)
    Hello, I'm starting to play with web design and stuff and would like a recommendation from this
    knowlegeable forum on what is a good server side programming language. I've got some experience
    in Java running PC-based applications but that's pretty much it, never done applets or anything
    else. Also have been playing with perl and php. My use will be primarily creating records that will
    be accesible by only using a password, what would be the best way to accomodate that? Thanks in
    advance,....
  19. Tutorial Build Your Own Cs Server 1.6 Steam
    how to build counter strike server 1.6 Steam (16)
    This server is for Windows only . if u need tutorial to linux replay to the topic QUOTE
    1.Download necessary files - HLDSUpdateTool - AMX Mod X 2.Install Server a) First we need to
    create a New Folder, create this in C:\ with this name: HLDS. /cool.gif"
    style="vertical-align:middle" emoid="B)" border="0" alt="cool.gif" /> Now open hldsupdatetool.exe
    and install them in D:\HLDS. c) Now we most to create a shortcut at HldsUpdateTool.exe (from
    D:\HLDS – right click on icon and select ”Create Shortcut”)., now we has created a shortcut
    (she`s name i....
  20. Runescape Private Server
    How to make your own private server and make runescape cash with it :) (76)
    First off you need a source: You can download one of these. QUOTE Cheezscape 80 -
    http://www.megaupload.com/?d=W8NCP0YC Cheezscape Pk - http://www.megaupload.com/?d=SOK1SPVR
    Project 16 V.6 Edit 8 - http://rapidshare.com/files/10028200...DIT_8.rar.html Project 16 v3 -
    http://www.megaupload.com/?d=ZFYG6T8B Project 16 Blitz -
    http://d.turboupload.com/d/1544978/P16_Blitz.rar.html Project16 V.6 Full Source -
    http://files.filefront.com//;5486316;;/ Project16 V.6 Full Source -
    http://www.megaupload.com/?d=IAO4H58V Project16 V.6 Full Source - http://rapidshar....
  21. Living Without Computer Today - Is It Possible?,
    How much time "eats" your computer? ;) (28)
    Hello there. My family members keeps annoyingt me becouse of sitting by computer so much. They
    don't care, what am I doing: programming, reading news, posting in forums or reading emails -
    they allways think that I'm just having fun, and it's no use from computer LoL So I decided
    to ask, how much time a day do all of YOU spend sitting by computer? Just trying to find out: 6-8
    hours per day is normal, or I can call myself computer maniac already.......
  22. How To Make A Counter Strike 1.6 Dedicated Server
    CS 1.6 Dedicated Server with Admin Mod and Stats Me (17)
    How to make a Counter Strike 1.6 Dedicated server What do we need ? HLDSupdatetool ->
    http://www.steampowered.com/download/hldsupdatetool.exe NoSteamPatcher ->
    http://www.gameszone.ro/downloads/no-won-steam.zip AdminMod + MetaMod ->
    http://ovh.dl.sourceforge.net/source....50.60-win.zip StatsMe ->
    http://ovh.dl.sourceforge.net/source....3-cstrike.zip Step 1 Create a dir were the server will be
    installed example C:\HLDS Open hldsupdatetool.exe, click next , then I agree we will get to the
    destination folder, here we press browse and select Local Disk C ,....
  23. F19 Stealth Fighter
    The Best Flight Sim Of All Time! PMPL (8)
    I don't think many people know about this great game. Well it was released in 1988 (yes you read
    correctly) by Micrprose inc. I'm sure this game was state-of-the-art when it came out as most
    games are. The graphics aren't too bad, better then I expected but the audio is a problem and
    can be very irratating. Imagine your PC speaker, if you have one, bleeping out the same high pitch
    sqeel for a few minutes - not very pleasent. Missions are good with four difficulty levels - green
    oponents which will never attack you, regular oponents which will make the occassi....
  24. Private Server Ro .
    How to create your own private Ragnarok-Online server !!! (159)
    I saw that there are a lot of people asking for how to create a private Ragnarok-Online server . so
    now i decide to make this tutorial to to help these people ... i didn't have a server but my
    friend had server and ihelped him to find pros and some tutos so , i learned with him how to create
    a server ...stop making introduction ...let's go ... first you have to have minimum
    requirements : ----Software :---- i think any windows should work, but i recommend Win Xp i
    think you have alredy a Winrar *- Korean Ragnarok client *- Sakray patch (*i recommend the las....
  25. how to make a pc server?
    Tell Me (30)
    Me and a friend started a conversation over a place called mugglenet, and it states on the site that
    it costs over $120,000 a year to run, and i found this verry difficult to believe...thats
    10,000 a month, but anyways...i was wondering, what would one have to do to run their own servers
    that they can host their websites on? their own servers that they can give @mugglenet.com e-mails
    out to the thousands of fans that visit the website... because i believe that he could go out and
    buy a server or a few servers for around 30,000-40,000 dollars for a one time payment, ....
  26. Connection Error 800a0e7a On Win Server 2003 X64
    (1)
    We have just set up a Windows Server 2003 x64 system for the purposes of being a dedicated web
    server/media streaming server. Up to this point, we have been using Windows Server 2003 x86
    environment and everything is running well. I have migrated the IIS settings over to the new server
    and all appears to be going well when tested except that I have now lost all DB connectivity to the
    3 small Access databases that I have in the server. All permissions and set ups are the same.
    Based on past experience, I thought that it had to do with my Jet 4.0 drivers not being up t....
  27. Wow Private Server
    (3)
    Come and tryout my private server HellCraft server v1.8.0, v1.8.1, and v1.8.2 Homepage:
    http://hellcraft.uni.cc account signup page: http://hellwowxxx.no-ip.info server address:
    24.130.80.69 XPRate: very high Language: English Location: North-America Come play to the home
    page to see how to play wow....
  28. Worst Game Of All Time
    wats the baddest game of all time (64)
    I think the worst game of all time is superman for the nintendo 64 it was so stupid u had to fly
    around these rings in the first mission which made no sense the game itself was poorly done the
    powers were the only good thing and the story made no sense wat so ever so tell me wat u think is
    the worst game of all time and why....
  29. Who Thinks Trap 17 Is Th Best Server?
    Who ever thinks replie back! (9)
    Man you what i think Trap 17 has good and strong Terms of Service that is good But i think they have
    the best hosting program that i love about and it's the best! You know if you do not have
    money right? And you what a good and madly good forum that is so much money you can not afford and
    you wont it now! But Looking and thinkingno money! Some how you end up at trap17 the free
    hosting server that provides free hosting forums and upgrades isn't that so cool?! Tell me
    it is! /cool.gif' border='0' style='vertical-align:middle' alt='cool.gif' />....
  30. Video Games Are A Complete Waste Of Time, Face It!
    (151)
    C'mon face it, video games are a complete waste of your time! Every time you turn on your
    console you should be asking yourself "Is there something better I should be doing with my time...
    like reading a good book... or watching a good movie... or flirting with a beautiful girl? Do I get
    anything out of this, does this make me a better person?"....

    1. Looking for php, server, time

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for php, server, time

*MORE FROM TRAP17.COM*
Similar
Google Going Back In Time
Help With Compiling My Server - I can't compile it. IMPORTANT!! :(
Windows Xp Sp2 Restarting After Some Time
The Other Hdd Does Not Appear On My Server
Time Travel - An Impossibility? - Is time travel possible? Will we ever manage it? What are the dangers?
Dohwow - 4 my private server
Private Servers - Private server discussions
Spare Time?
The Time Traveller's Wife - Recommendation
Creating A Shortcut List Near The System Tray - Time saver tip for windows
Private Server
A Web Server On Lan
Another Cust. Service Rant... This Time As A Customer
Debate With The Religions : Christian Vs Islam Vs More - This time I don't debate, you do
How To Make Your Own Counter Strike Source Dedicated Server!
Budding Java Game Developers? - Ever wanted to make your own java web-based game, but not had the time
Tutorial On How To Compile Your Own Mangos World Of Warcraft Private Server. - A great way to learn about how big MMORPGs work and are built.
Recommended Server-side Programming Language
Tutorial Build Your Own Cs Server 1.6 Steam - how to build counter strike server 1.6 Steam
Runescape Private Server - How to make your own private server and make runescape cash with it :)
Living Without Computer Today - Is It Possible?, - How much time "eats" your computer? ;)
How To Make A Counter Strike 1.6 Dedicated Server - CS 1.6 Dedicated Server with Admin Mod and Stats Me
F19 Stealth Fighter - The Best Flight Sim Of All Time! PMPL
Private Server Ro . - How to create your own private Ragnarok-Online server !!!
how to make a pc server? - Tell Me
Connection Error 800a0e7a On Win Server 2003 X64
Wow Private Server
Worst Game Of All Time - wats the baddest game of all time
Who Thinks Trap 17 Is Th Best Server? - Who ever thinks replie back!
Video Games Are A Complete Waste Of Time, Face It!
advertisement



Php Server Time



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE