/    Sign up×
Community /Pin to ProfileBookmark

mktime(gmdate) loses a day wtf?

When I run this code:

[code=php]echo ‘<br />Current UTC ‘.gmdate(“H, i, s, m, d, Y”);
$gmtmst = mktime(gmdate(“H, i, s, m, d, Y”)); // get current UTC time
echo ‘<br /<pre>’;
print_r(getdate($gmtmst));
echo ‘</pre>’; [/code]

I get this:

[CODE]Current UTC 06, 00, 47, 02, 28, 2008

Array
(
[seconds] => 47
[minutes] => 0
[hours] => 6
[mday] => 27
[wday] => 3
[mon] => 2
[year] => 2008
[yday] => 57
[weekday] => Wednesday
[month] => February
[0] => 1204120847
)
[/CODE]

WTF?

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@treelovinhippieauthorFeb 28.2008 — OK, a lot more searching and apparently to do this very, very simple function you need to use this code:

[code=php]$gmtmst = strtotime(gmdate("M d Y H:i:s", time()))[/code]
×

Success!

Help @treelovinhippie 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.25,
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,
)...