I use the date helper in CI to save the timezone of the user when he signup eg: UM45.
I want to set the timezone of each user based on that and display the date time correspondingly, using date_default_timezone_set().
But that accepts only string.. How can I get the name of the timezone based on UM45?
Seems it can be done via the Language Class:
$this->lang->load('date_lang');
$this->lang->line('UM45');
Related
In phpinfo, default.timezone & default.datetime as America/New_york.
In joomla configuration file offset as "America/Newyork". Offset user as "UTC". In backend user setting as "Newyork."
Actually the problem as When i create a article, the time save as as UTC format in database, But when we view the created date in the article, it shows 5 hours ahead to the created time. Whenever i save the article it increase 5 hours from the current date.
Please advice.. Thank you.
Add this line as the first line in your code,
date_default_timezone_set('Asia/Kolkata');
Change the timezone ('Asia/Kolkata') to your timezone.
You can check your timezone name Here.
If it is specific about Joomla, then
using JHtml::('date' , ....) for output
https://compojoom.com/blog/entry/how-to-use-jdate
Also, When you call JFactory::getDate() it will construct a JDate object, which already takes the timezone into account.
More info:
http://docs.joomla.org/How_to_use_JDate
http://api.joomla.org/cms-3/classes/JDate.html
http://api.joomla.org/cms-3/classes/JFactory.html#method_getDate
Finally, I found the issue in the server timezone. I have changed the server timezone to GMT/UTC. it was working fine. Thanks for all your contribution
I have a MySQL database that records the time when a given event occurs. There's a web app that show's these times when you load the page BUT its in +0 TimeZone. I want this to show what ever timezone that the user is in.
echo(date('l F jS Y h:i:s A', ($row["date"]/1000)- 3600*6));
The above code shows that if I want the timezone to be central I have to *6. But this would just be the new timezone then and doesn't change based on users location.
Also a added bonus would to be able to display at the top of the page somewhere the users IP address, City and State.
EDIT:
Trying to get the UTC timezone # into a $variable.
Example being Central Time would = -6.
echo(date('l F jS Y h:i:s A', ($row["date"]/1000)-(3600*(-1*$variable))));
If you want to have the correct time zone set on page load you are going to need to store the users time zone as a preference in your application. Unfortunately PHP (or any backend language) for that matter does not have access to such browser information (unless you additionally pass it to the server-side script).
The other option is to pass the UTC date or server timezone date, get the user's time zone and convert your date to their local time using Javascript.
You can get the UTC time zone offset with
var d = new Date()
d.getTimezoneOffset();
I am working on a Symfony2 based website where client can request users to post at a particular time of the day for exemple from 9pm to 10pm.
Users are coming from all over the world and if a client request a post at 9pm, it s not based on his local time but on the user that will post for him.
Should i request my user what is his timezone and store it and then use it to convert the php DateTime of his post to his time zone and then check if he posted it at 9pm ? Could you show me a little code exemple for that ?
Also, what is the good way to ask a user his timezone ?
Edit : I want to ask the user his timezone and not get it programmatically because its actually his audiance timezone ( people who see his posts ) and not his personnal timezone.
best way is to use js timezone detection with library jsTimezoneDetect
next send via ajax request timezone to save in session
next use timezone in session to set timezone to date, you probably want to make twig extension for that so you can use it easily in twig.
1. all your dates must be in same timezone, for example UTC
you can set it in AppKernel.php
date_default_timezone_set('UTC');
to display date use something like this
$date->setTimezone(new \DateTimeZone($timezone));
where date is \DateTime object
if you want to ask user anyways you can create form with:
you create a form, use http://symfony.com/doc/current/reference/forms/types/timezone.html
field
and send that timezone to controller (AJAX or standard), set session with timezone, and for the rest handle it like like I described above by displaying date via your custom twig extension etc.
My file tracking system deals with application submission. Date of the application is used to track total days taken to process each application. However, event though current date is shown, user able to change it to past date in my system. The system use mvc framework. What should i do to make the date inaccessible by user? Something like static.
Just store the date against the application id in the database when the application is first submitted and then ignore any mention of the date in the submitted form data.
I am working on rss parser project, I need to fetch URL from us based server and store the data in to database while storing/viewing I need to keep the post time.
I am using simplepie for rss aggregation, I face the following problem while handling rss
while I am checking rss url in firefox 3.0.19/system timezone set to Chennai/Kolkatta/Mumbai(UTC+5:30)now firefox displays post time for the post is 10:51 am
at the same time if i check the same url in another system which has firefox 3.6.1/system timezone set to Chennai/Kolkatta/Mumbai(UTC+5:30) now firefox displays post time for the post is 11:34 am
how do I know which time is correct?
and how do I get timezone for the RSS Server for php
RSS Feeds stored in one server and I installed PHP application in another server both of them located in us.
Which timezone should I use?
i set following time zone in my code
<?php
date_default_timezone_set('US/Central');
?>
but post time is wrong when display
i solved the problem my self using below method
get list of all timezones take first post's post date and set the first timezone format the date and set the second timezone format the date and so on.. finally i compared formatted date with postdate then i got the timezone of the server