/    Sign up×
Community /Pin to ProfileBookmark

MySQL datetime / timezone issue

I’ve set my timezone to pacific/auckland in my PHP ini file. when I echo the time() in date format it’s correct.

How can I retrieve records where ‘datetime’ is past this time when the MySQL server time (which I can’t change) is differnt?

MySQL DateTime: 2021-11-10 11:50:00.000000

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@kiwisauthorNov 18.2021 — I've tried this

<i>
</i> WHERE UNIX_TIMESTAMP(CONVERT_TZ(<span><code>myDateTimeCol</code></span>, 'NZT', 'CST')) &lt;= 1637227300 <br/>
Copy linkTweet thisAlerts:
@NogDogNov 18.2021 — I don't have access to MySQL, but I _think_ you could just specify TZ in your value being compared, e.g.:
[code=sql]
WHERE myDateTimeCol <= '2021-11-18 12:34:56+12:00'
[/code]

You should be able to get your PHP to generate that string via date():
[code=php]
$where_date = date('Y-m-d H:i:sP');
[/code]
Copy linkTweet thisAlerts:
@kiwisauthorNov 18.2021 — @NogDog#1639560

Yes I had it in my head I needed to convert my PHP to unix timestamp based on my MYSQL server time or covert the SQL time to NZ time. But in fact I just needed to compare the fixed string in the database against a created string from PHP.
Copy linkTweet thisAlerts:
@yaovisamahNov 19.2021 — *TrustyFans*

*TrustyFans* is a social media that makes users money when they sign up for it.

*HOW DOES IT WORK?*

*TrustyFans* is multi contents creator platform(Youtuber, instagrammer, Vlogger, designer, influencer, etc...) that makes users to earn money from the content they share with their followers and subscribers.

*How to Sign Up:*
  • 1. Access the website link https://trustyfans.com.


  • 2.Create your account, or use google to login

  • 3. Check your email to confirm your account registration.


  • *HOW TO BECOME A CONTENT CREATOR?*

    After a successful sign up,

    1.Access the platform and click on BECOME CONTENT CREATOR from the menu button.

    2.Provide your id card and submit it. Wait patiently for your application to get approved.

    *HOW TO EARN GOOD MONEY FROM TrustyFans?*

    *TrustyFans* has been designed in such a way that, users get to earn 70% of their content revenue.

    Users earn based on the fee they set for both their followers and subscribers either on a weekly, monthly, or yearly basis.

    *TrustyFans* is a multipurpose social media platform where you can earn from live streaming, or the content you post on your page. Unlike other social medias, Trusty fans gives your followers and subscribers to opt into your premium feeds so you get paid for it.

    *TrustyFans* can make users earn on weekly basis, monthly and yearly basis.

    You can post free content and premium content as well but for someone to view premium contents on your channel, the person has to pay or subscribe to it.

    *HOW TO SET YOUR FEES*

    1-Check setting panel, click on fee, set up weekly, monthly & yearly fee you want your subscribers to pay, save it and you are good to go

    *TrustyFans*; the only good, genius & legit forum platform where you can earn good money from your followers.

    JOIN NOW TO START MAKING MONEY

    Get in touch : [email protected]

    https://trustyfans.com
    Copy linkTweet thisAlerts:
    @ginerjmNov 19.2021 — Do you have a PHP question? Cause if you don't get the he... out of here. Dingbat.
    Copy linkTweet thisAlerts:
    @kiwisauthorNov 19.2021 — @ginerjm#1639646 It's call spam
    Copy linkTweet thisAlerts:
    @fabian076Nov 22.2021 — Hello, it is enough to compare the set string in the database with the string created with PHP, I had it too, but I compared it and now it is very good, as it should, I was wondering for a long time how to do it, but finally it worked[.](https://casinoteam.org)
    ×

    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 4.18,
    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,
    )...