/    Sign up×
Community /Pin to ProfileBookmark

GMT Date and Time Print PHP Modification

Hello there,

Can someone please let me know how I modify this…

<?php
date_default_timezone_set(‘Europe/London’);
echo date(‘l jS F Y, h:i A e’, time());
?>

to show…

Wednesday 23rd April 2014, 10:52 AM [B][COLOR=”#FF0000″]London GMT[/COLOR][/B]

instead of…

Wednesday 23rd April 2014, 10:52 AM [B][COLOR=”#0000CD”]Europe/London[/COLOR][/B]

Thank you for any assistance provided.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@Sup3rkirbyApr 23.2014 — You could just use:
[code=php]
<?php
date_default_timezone_set('Europe/London');
echo date('l jS F Y, h:i A', time()) . " London GMT";
?>
[/code]


The '[I]e[/I]' in the [B]date()[/B] function displays the timezone identifier, which is '[I]Europe/London[/I]'. As far as I know there is not a timezone identifier in PHP that is '[I]London GMT[/I]', thus the [B]date()[/B] function can't actually return that part of the string you want. Thus it's easier to just add it to the end as an actual string as demonstrated above.
×

Success!

Help @riz-man 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.28,
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,
)...