Note that there are some explanatory texts on larger screens.

plurals
  1. PODealing with PHP timezone according to user
    primarykey
    data
    text
    <p>Well I know that this question may be asked many times but certainly I've few doubts In my mind, and by the way don't comment that what I've tried, I've tried many ways but am just asking what's the correct and easier way as there are many posts lingering out here with different suggestions for accomplishing these tasks, so I'll <code>explode()</code> my question into smaller questions...</p> <p>So can you people just guide me where am going right or wrong as am sure many people are confused when it comes to date/time</p> <p>1) Why/how to save time as UTC in MySQL using PHP? Personally for this I post this using php <code>$year/$month/$day</code> and check the date using <code>checkdate()</code> in mysql date field. so is it ok or should I use <code>timestamp</code> and than explode the retrieved string on front end using php?</p> <p>2) If I run server from India, should I record default time using <code>date_default_timezone_set("Asia/Calcutta");</code> and than subtract and add time using php function or while posting only I should check users time zone selected from his user accound and accordingly set a condition kinda:</p> <pre><code>if(timezoneselected == +5.30) { echo date_default_timezone_set("Asia/Calcutta"); } elseif(timezoneselected == +anytime) { echo another country timezone } </code></pre> <p>3) last question is how websites like gmail facebook etc manages time? I mean if they are saving datetime according to their server than how they show perfect posted time for each user, even gmail, if I send a mail to another user, my sent time and the person living in another country gets email at his printed local time I mean how we can do this, sorry am not able to explain you perfectly say this example,</p> <p>facebook: user from India posts, facebook shows posted 8 mins ago, 9mins ago, fine after sometime they show a real date, and that date is perfect according to the time I posted, however if a person from USA updates, say 8 mins ago 9mins ago on his profile but his original posted time is shown correctly to him, and even correctly to me?</p> <p>sorry for this question but really this will help me understanding this date/time concept and will also be helpful to future users. Thank you!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload