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;
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
add a comment |
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
@JoeYdoanRauzes Hi, you probably don't get the question. I need to selectmessages
that needs to be sent onschedule
time ifschedule time <= NOW() in each user timezone
(timezone is stored inuser.timezone
field.
– user4785882
Mar 24 at 12:47
add a comment |
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
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
php mysql datetime timestamp
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 selectmessages
that needs to be sent onschedule
time ifschedule time <= NOW() in each user timezone
(timezone is stored inuser.timezone
field.
– user4785882
Mar 24 at 12:47
add a comment |
@JoeYdoanRauzes Hi, you probably don't get the question. I need to selectmessages
that needs to be sent onschedule
time ifschedule time <= NOW() in each user timezone
(timezone is stored inuser.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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
@JoeYdoanRauzes Hi, you probably don't get the question. I need to select
messages
that needs to be sent onschedule
time ifschedule time <= NOW() in each user timezone
(timezone is stored inuser.timezone
field.– user4785882
Mar 24 at 12:47