How to get exact ist time in php?

In php, I used a date function (for example: date('Ymd hm-s') ), it does not display the current time. Please help me...

+4
source share
7 answers

Update:


Here's how you can set the time zone for your region:

 if (function_exists('date_default_timezone_set')) { date_default_timezone_set('Asia/Mumbai'); } 

It should work fine. Also note that you did not specify the minutes correctly. Use i for minutes not m :

 date('Ymd hi-s') 

And make sure echo it:

 echo date('Ymd hi-s'); 
+6
source

Do you want Indian time. This is my decision. You can use either Asia/Calcutta or Asia/Kolkata . both will be returning at the same time.

 date_default_timezone_set('Asia/Calcutta'); echo date('Ymd hi-s'); 

It worked for me. Try it ...

+17
source
 if (function_exists('date_default_timezone_set')) { date_default_timezone_set('Asia/Calcutta'); } 
+3
source

change timezone according to ur need and then try

 date('-r') 
+1
source

You can try the following:

 date('Ymd hi-s',strtotime('+330 minute')); // where +330 min (difference of indian time zone with gmt) 
+1
source
 date_default_timezone_set('Asia/Kolkata'); // this sets time zone to IST echo date_format(new DateTime(),'d MYH:i:s'); // this gives you date and time 
0
source
 date_default_timezone_set('Asia/kathmandu'); echo date('Ymd hi-s'); 

That should work. You can see your time zone at http://www.worldtimezone.com .

0
source

Source: https://habr.com/ru/post/1341764/


All Articles