Skip to main content

Solutions In Drupal

Time Zone Handling in Drupal 7favorite
I got a below scenario in one of my project and i was totally strucked up .Dont know how to proceed further , Any help is much appreciated
I have a date field saved as Unix timestamp with site's timezone .With the new requirement, have new local timezone field with limited options so that admin enter can enter the event date with the local timezone where that event actually happen.
For Example in the date field they may enter Apr 04 2018 07:00 am and the local timezone field is maintained by creating select field with limited option as EST, CDT, MST etc..., so they can use choose any one of them.
I have created the views for the next immediate event by comparing the relative date
using the result date need to display the counter like functionality for example 1days : 30 hours: 15mins: 20 seconds.
To make a counter have using the javascript in view field tpl
var event_date = ;// View output in date format
var countdown = new Date (event_date).getTime(); //event date in timestamp
var local_time = new Date().getTime();// clent local time in timestam
var distance = countdown - local_time;
var days = Math.floor(distance / (1000 * 60 * 60 * 24)); var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); var seconds = Math.floor((distance % (1000 * 60)) / 1000);
Now its working only for site's time zone . What am expecting is ,if a user enter the event date in CDT time zone , then site display the exact time diffence when the event going to start at their timezone(local)...

Comments

Popular posts from this blog

Things You Must Know Before Trying Forms In Drupal 8.

 You Should Invest In Forms                      What does your customer think?  What do they looking for? will decide the success of any business.    In a digital marketing, Most of the customer requirement is gathered through forms. So its   essential  to spend some  time with forms Example : a user can search a particular product using the search form on an e-commerce website. Form API in Drupal 8          As we know already Drupal use forms for most of the administrative site building. Drupal 8 follows object-oriented style of programming with the integration of symfony . Based on the purpose of the form, it can inherit the basic properties and methods of the below classes. 1.Config Base 2.FormBase 3.ConfirmBase   Note : Routing configuration is done through the yml files in drupal 8 When the user hits the va...

What is Drupal ? What is Content Management System??

Before  Diving into Drupal 8 Learning ,                                                One who must know what is drupal . What is Drupal ? Drupal  is one among the Content Managment System . Then next rising  question is What is   Content Management System  . ?   To explain about Content Mangement System lets start with an example If you want to sell your products in online , you can sell by passing some of the information about your product in web by giving Name of the Product Image of the Product  Price of the Product ....etc As a whole you are describing your content For managing large amount of data like this you need a system for flexibility  and ease of use So you may think like developing a system from scratch to sell a product Ohhhhh !!!!!!!!!!!!!!!!!!!!!!!Nooooooooooooooooo!!!! ...

Comparison Between Drupal 7 and Drupal 8

Well in the learning process of drupal ........, This is my second post..if you missed previous article please refer the following  link. What is drupal and what is cms As i said in my pervious article ,drupal is an open source framework .We can easily download it from  Drupal  official link. As a extensive contibution of drupal community we are getting improved versions of drupal. Currently   Drupal 7 and Drupal 8 is activily maintained by the community. Lets find out the major difference between drupal 7 and drupal 8 Structure 1.Drupal 7 is based on procedural programming 2.Drupal 8 is  mainly focused on object oriented programming Template engine 1.Drupal 7 is based on the  php template engine 2.Drupal 8 is based on  twig template engine Routing 1.page callback functions are utilised  for each every page request   in drupal 7 2. Yml files are used to handle the routing configuration of the each p...