Domanda

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

È stato utile?

Soluzione 4

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.

Altri suggerimenti

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

use it when you insert your event date time

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

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top