How to select a datetime related to timezone in mysql for each user(if users has a different timezones)How to return only the Date from a SQL Server DateTime datatypeConvert from MySQL datetime to another format with PHPHow do you set a default value for a MySQL Datetime column?How do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of user accounts using the command line in MySQL?Retrieving the last record in each group - MySQLHow to make an unaware datetime timezone aware in pythonHow to reset AUTO_INCREMENT in MySQL?How to import an SQL file using the command line in MySQL?

Please help me identify this plane

Do adult Russians normally hand-write Cyrillic as cursive or as block letters?

Is American Express widely accepted in France?

Short story written from alien perspective with this line: "It's too bright to look at, so they don't"

Anyone teach web development? How do you assess it?

Working in the USA for living expenses only; allowed on VWP?

How to detach yourself from a character you're going to kill?

What does it mean by "d-ism of Leibniz" and "dotage of Newton" in simple English?

Computing the differentials in the Adams spectral sequence

Unconventional Opposites

Can an old DSLR be upgraded to match modern smartphone image quality

Why were the Night's Watch required to be celibate?

Are there practical reasons to NOT use a stepper motor with lead screw for the X and or Y axes?

Credit card offering 0.5 miles for every cent rounded up. Too good to be true?

How can a single Member of the House block a Congressional bill?

Explain Ant-Man's "not it" scene from Avengers: Endgame

Pros and cons of writing a book review?

Is there any Biblical Basis for 400 years of silence between Old and New Testament?

Incremental Ranges!

Did Darth Vader wear the same suit for 20+ years?

Restoring order in a deck of playing cards (II)

Setting extra bits in a bool makes it true and false at the same time

What's the most polite way to tell a manager "shut up and let me work"?

PhD student with mental health issues and bad performance



How to select a datetime related to timezone in mysql for each user(if users has a different timezones)


How to return only the Date from a SQL Server DateTime datatypeConvert from MySQL datetime to another format with PHPHow do you set a default value for a MySQL Datetime column?How do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of user accounts using the command line in MySQL?Retrieving the last record in each group - MySQLHow to make an unaware datetime timezone aware in pythonHow to reset AUTO_INCREMENT in MySQL?How to import an SQL file using the command line in MySQL?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I have a system where I need to schedule messages.
Each user has its own timezone.
I have one server and server timezone is set to EET.
Db tables:



messages:
id int not null,
user_id int,
schedule DATETIME DEFAULT NULL

user:
id
name
timezone: string (php compatible timezone string e.g. Europe/Paris, Europe/Budapest, etc)


So I want to create a cron job, to check the database each minute and check if there are any messages I need to send.
But here I got stuck with these timezones.



I store DateTime with timezone offset, like so:



new DateTime('2019-01-01 01:01:01', new DateTimeZone('Europe/Paris'));



So now I have a problem:
I can't use such query, because timezone is not checked.



SELECT * FROM messages as m 
JOIN user as u
ON u.id = m.user_id
WHERE m.schedule <= NOW() ORDER BY id DESC;


So I need to find a solution, how to get messages according to a user timezone.
Example:



1st user timezone: `CET + 2`
2nd user timezone: `CET + 3`
server time: `CET + 5`
I need to get messages according to each users DateTime + timezone.


Maybe store it in UTC and compare on php side, but I think there might be a better solution.



one more solution is to SELECT DISTINCT timezone from user



and then select messages according to each time zone separately.










share|improve this question
























  • @JoeYdoanRauzes Hi, you probably don't get the question. I need to select messages that needs to be sent on schedule time if schedule time <= NOW() in each user timezone (timezone is stored in user.timezone field.

    – user4785882
    Mar 24 at 12:47

















1















I have a system where I need to schedule messages.
Each user has its own timezone.
I have one server and server timezone is set to EET.
Db tables:



messages:
id int not null,
user_id int,
schedule DATETIME DEFAULT NULL

user:
id
name
timezone: string (php compatible timezone string e.g. Europe/Paris, Europe/Budapest, etc)


So I want to create a cron job, to check the database each minute and check if there are any messages I need to send.
But here I got stuck with these timezones.



I store DateTime with timezone offset, like so:



new DateTime('2019-01-01 01:01:01', new DateTimeZone('Europe/Paris'));



So now I have a problem:
I can't use such query, because timezone is not checked.



SELECT * FROM messages as m 
JOIN user as u
ON u.id = m.user_id
WHERE m.schedule <= NOW() ORDER BY id DESC;


So I need to find a solution, how to get messages according to a user timezone.
Example:



1st user timezone: `CET + 2`
2nd user timezone: `CET + 3`
server time: `CET + 5`
I need to get messages according to each users DateTime + timezone.


Maybe store it in UTC and compare on php side, but I think there might be a better solution.



one more solution is to SELECT DISTINCT timezone from user



and then select messages according to each time zone separately.










share|improve this question
























  • @JoeYdoanRauzes Hi, you probably don't get the question. I need to select messages that needs to be sent on schedule time if schedule time <= NOW() in each user timezone (timezone is stored in user.timezone field.

    – user4785882
    Mar 24 at 12:47













1












1








1








I have a system where I need to schedule messages.
Each user has its own timezone.
I have one server and server timezone is set to EET.
Db tables:



messages:
id int not null,
user_id int,
schedule DATETIME DEFAULT NULL

user:
id
name
timezone: string (php compatible timezone string e.g. Europe/Paris, Europe/Budapest, etc)


So I want to create a cron job, to check the database each minute and check if there are any messages I need to send.
But here I got stuck with these timezones.



I store DateTime with timezone offset, like so:



new DateTime('2019-01-01 01:01:01', new DateTimeZone('Europe/Paris'));



So now I have a problem:
I can't use such query, because timezone is not checked.



SELECT * FROM messages as m 
JOIN user as u
ON u.id = m.user_id
WHERE m.schedule <= NOW() ORDER BY id DESC;


So I need to find a solution, how to get messages according to a user timezone.
Example:



1st user timezone: `CET + 2`
2nd user timezone: `CET + 3`
server time: `CET + 5`
I need to get messages according to each users DateTime + timezone.


Maybe store it in UTC and compare on php side, but I think there might be a better solution.



one more solution is to SELECT DISTINCT timezone from user



and then select messages according to each time zone separately.










share|improve this question
















I have a system where I need to schedule messages.
Each user has its own timezone.
I have one server and server timezone is set to EET.
Db tables:



messages:
id int not null,
user_id int,
schedule DATETIME DEFAULT NULL

user:
id
name
timezone: string (php compatible timezone string e.g. Europe/Paris, Europe/Budapest, etc)


So I want to create a cron job, to check the database each minute and check if there are any messages I need to send.
But here I got stuck with these timezones.



I store DateTime with timezone offset, like so:



new DateTime('2019-01-01 01:01:01', new DateTimeZone('Europe/Paris'));



So now I have a problem:
I can't use such query, because timezone is not checked.



SELECT * FROM messages as m 
JOIN user as u
ON u.id = m.user_id
WHERE m.schedule <= NOW() ORDER BY id DESC;


So I need to find a solution, how to get messages according to a user timezone.
Example:



1st user timezone: `CET + 2`
2nd user timezone: `CET + 3`
server time: `CET + 5`
I need to get messages according to each users DateTime + timezone.


Maybe store it in UTC and compare on php side, but I think there might be a better solution.



one more solution is to SELECT DISTINCT timezone from user



and then select messages according to each time zone separately.







php mysql datetime timestamp






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 24 at 12:55







user4785882

















asked Mar 24 at 12:34









user4785882user4785882

42110




42110












  • @JoeYdoanRauzes Hi, you probably don't get the question. I need to select messages that needs to be sent on schedule time if schedule time <= NOW() in each user timezone (timezone is stored in user.timezone field.

    – user4785882
    Mar 24 at 12:47

















  • @JoeYdoanRauzes Hi, you probably don't get the question. I need to select messages that needs to be sent on schedule time if schedule time <= NOW() in each user timezone (timezone is stored in user.timezone field.

    – user4785882
    Mar 24 at 12:47
















@JoeYdoanRauzes Hi, you probably don't get the question. I need to select messages that needs to be sent on schedule time if schedule time <= NOW() in each user timezone (timezone is stored in user.timezone field.

– user4785882
Mar 24 at 12:47





@JoeYdoanRauzes Hi, you probably don't get the question. I need to select messages that needs to be sent on schedule time if schedule time <= NOW() in each user timezone (timezone is stored in user.timezone field.

– user4785882
Mar 24 at 12:47












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55323840%2fhow-to-select-a-datetime-related-to-timezone-in-mysql-for-each-userif-users-has%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55323840%2fhow-to-select-a-datetime-related-to-timezone-in-mysql-for-each-userif-users-has%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript