/    Sign up×
Community /Pin to ProfileBookmark

working with date time simple question :-)

Afternoon all 🙂

I’ve built a function that records what is downloaded, and by who’m on my website. The last thing that is left is to record the date.

I have it recording fine & I calculate the date using

[code=php]
$date = date(“Y-m-d G:i:s”);
[/code]

however, the time returned is 1hour ahead of me (assuming thats because of the locality settings on my service provider) How can I adjust the value returned by

[code=php]
$date = date(“Y-m-d G:i:s”);
[/code]

To take this into account or alternatively amend it after its returned and just before i submit it to the database?

Many thanks in advance.
Leigh

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@aj_nscMar 27.2007 — Set the timezone before you do your date calculations.

Something like this:
[code=php]
//this is my timezone
date_default_timezone_set("America/St_Johns");
[/code]


For a complete list of timezone abbreviations, check out php.com
Copy linkTweet thisAlerts:
@bokehMar 27.2007 — There are lots of ways. Maybe:[code=php]$date = date("Y-m-d G:i:s", time()-(60*60));[/code]
Copy linkTweet thisAlerts:
@LeighRogersauthorMar 27.2007 — Thank you very much!!

[code=php]$date = date("Y-m-d G:i:s", time()-(60*60)); [/code]

worked perfectly :-)

Thanks again - Much appreciated!
×

Success!

Help @LeighRogers spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...