/    Sign up×
Community /Pin to ProfileBookmark

SELECT records from yesterday

I’ve got PHP INI file make my PHP time setting my local timezone.

I’m adding rows to a database including a added timestamp.

I’m now wanting to retrieve records from my database entered yesterday. My SQL server time is US Central time. Not my php timezone.

Do I have to work out the start of yesterday in PHP time stamp and add that to my query or can I do this in a SQL command without doing so.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogDec 30.2020 — Crazy idea that might just work (or not):
[code]
$startTime = strtotime('yesterday'); // UNIX time for 00:00:00 yesterday
$endTime = strotime('today); // UNIX time for 00:00:00 today
$sql = "SELECT ... WHERE ts_col BETWEEN FROM_UNIXTIME($startTime) AND FROM_UNIXTIME($endTime)";
×

Success!

Help @kiwis spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...