I need someone to put me through on how i can show GMT time on my php application. I have tried all possible time functions all to no avail. i don't want the time to have anything to do with my system time because i want the application to automatically delete a row in my database on 12 midnight GMT every day.

I appreciate all usual supports.

Thanks in advance.

Try:

<?php
echo date('Y-m-d- G:i:s'); # systme
date_default_timezone_set("GMT");
echo date('Y-m-d- G:i:s'); # GMT
?>
commented: :) +14
Member Avatar for diafol

you need to set the timezone. A few ways, but I suppose the simplest is:

date_default_timezone_set('Europe/London');

OR if you specifically want GMT, just use GMT - I think that will avoid summer time changes specific for certain countries.

??EDIT

Bugger, beat me to it cereal - well that's payback for earlier I suppose! :)

commented: ;D +7

Hi ardav, thanks. I really want it for nigeria (gmt + 1). Can i specify nigeria in the function?

Check this.

I need to print the exact GMT Time on my application. but the date_default_timezone_set() is still echoing the system time.

Please help me.

Thanks.

Member Avatar for diafol

date_default_timezone_set() shouldn't echo anything - it sets. Anyway, show your code, we don't have the power of omniscience.

Below is the code.

<?php

date_default_timezone_set("GMT");

echo date('Y:M:d, G:i:s');



?>

I just want to use this to print it on a screen before i can embed it into the normal application. but it still echo system time.

Member Avatar for diafol
echo date('Y-m-d H:i:s') . "<br />";
date_default_timezone_set ('GMT');
echo date('Y-m-d H:i:s');

Works for me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.