0

So the thing here is that I have no clue nor know how to search for it on the internet. So, I shall begin explaining:

-Website(host) is located in a server with the UTC timezone
-I(administrator) am located on a CEST timezone
-When I(administrator) create an event with a specific date(let's X; format YYYY-MM-DD), what I want is that the event will not be available on the X day at 18:00 CEST, but until then the event is "on" and clients can see, if you know what I mean.
-After 18:00 of the day X, users(clients) will not be able to see more the event that then "passes" to the next date(let's Y) event.

I have no clue of how to search this on the internet, so, some guides are appreciated.

Language: SQL

calexandru
  • 307
  • 1
  • 3
  • 16

4 Answers4

2

You may try php's date_default_timezone_set function with value : 'Europe/Berlin'

date_default_timezone_set('Europe/Berlin');

Now your database will store the values for date according to 'Europe/Berlin' time.Implement the logic for your event showing conditions with Europe/Berlin timezone

  • But how ? I have no clues of when or how to implement this : / – calexandru May 15 '14 at 13:05
  • you just need to add the above function in your php file in starting, and use php date() function instead of mysql now() for saving event date in db then make where condition for fetching events with php's date() function again. Hope you understood what i want to say :P – Bharat Maheshwari May 15 '14 at 13:24
  • Yes yes!!!! Thank you, although I found a solution, I this one is also an alternative. Thank you very much for your time and help :) – calexandru May 15 '14 at 16:07
2

use it when you insert your event date time

switchoffset(sysdatetimeoffset(),'+02:00')

sanket
  • 77
  • 2
  • Found one thing about that: "It is a common best practice to store datetimes in UTC and do any conversion after the fact." So I get little confused in which and how to use. But that does seem a relative easy solution. – calexandru May 15 '14 at 13:06
  • yes u can store datetimes in UTC and do any conversion after that and it will be easy. – sanket May 15 '14 at 13:24
0

I think you will need to implement some javascript also, just to get user's timezone/time.
something along the lines:

var d = new Date();
var timezone = d.getTimezoneOffset();

Now you need to pass this to your server-side script and determine if your event will be on or off for that user

andrew
  • 2,058
  • 2
  • 25
  • 33
  • Hey @Andrew, the thing is that the timezone of the client is the same as mine, since it's like a private page for a football team and only those that are registered may login, and all of them have CEST timezone. – calexandru May 15 '14 at 13:04
  • 1
    @Sashka then ignore my hint :) – andrew May 15 '14 at 13:05
0

Database timezone

This responds a bit to my question. mysql> SET time_zone = 'timezone_name';

Now I have to discover how to build the query...

EDIT:

So after doing the above, I created the query select *, dayname(date) as day_name from dates where (date + interval 17 hour) > now()

Although I consider this one better for me(for now), there is also an alternative that Bharat Maheshwari mentioned above.(since I am working on a national scale, I do not need to check each users time-zone, so this made this job a bit easier.)

Thank you very much for the help and tips!!!

Have a nice day.

Community
  • 1
  • 1
calexandru
  • 307
  • 1
  • 3
  • 16