/    Sign up×
Community /Pin to ProfileBookmark

Timestamp -8 GMT

Hey all,
I have a timestamp in the sql server and when I call that field I get:

[code=html]2008-02-22 18:13:47[/code]

I need it to render:

[code=html]2008-02-22 10:13:47[/code]

How can I adjust the hours to reflect the timezone I’m in (or specify) without writing anything to the sql server again. Can I do it in the same page render that I get the initial timestamp from?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@iotaFeb 23.2008 — substract it if 24 hr format. I had same problem like you.
Copy linkTweet thisAlerts:
@towerboyauthorFeb 25.2008 — OK, I can figure out how to subtract the hours by "X" but what if it goes on to the previous day? Example:
[CODE]2008-02-22 05:13:47 subtract 8 hours = 2008-02-22 21:13:47[/CODE]
But the date stays the same. It should be:
[CODE]2008-02-21 21:13:47[/CODE]
What do you think I can do about that?
[code=php]if($hours < '0'){
$day = $day - 1;
}
if($day < '1'){
$month = $month - 1;
}
if($month < '1'){
$year = $year - 1;
}[/code]

Obviously I will need to explode the timestamp to get the individual values before it will work but am I on the right track or is there an easier way?
×

Success!

Help @towerboy 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 5.17,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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