Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8519471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:15:30+00:00 2026-06-11T06:15:30+00:00

I have looked at this question but time format is different I have following

  • 0

I have looked at this question but time format is different

I have following date format Tue, 11 Sep 2012 17:38:09 GMT
in $pubDate variable

I would like to compare $pubDate with current Date and Time to see if Tue, 11 Sep 2012 17:38:09 GMT is in last 10 mins or not

EDIT:

I have tried

//get current time
                strtotime($pubDate);
                time() - strtotime($pubDate);
                if((time()-(60*10)) < strtotime($pubDate)){
                    //if true increase badge by one
                    $badge = $badge + 1;
                }

it gives the warning:
It is not safe to rely on the system’s timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘America/New_York’ for ‘EDT/-4.0/DST’ instead in /Users/xxxxx/Desktop/xxxx/xxxx/xxxx.php on line 26

EDIT:

I have added date_default_timezone_set('America/New_York'); line to my php and now

$inDate  = DateTime::createFromFormat( $format, $pubDate);
    $postDate = new DateTime();

    $diff = $inDate->diff( $postDate);

    // If the total number of days is > 0, or the number of hours > 0, or the number of minutes > 10, then its an invalid timestamp.
    if( $diff->format( '%a') > 0 || $diff->format( '%h') > 0 || $diff->format( '%i') > 10) {
     die( 'The timestamps differ by more than 10 minutes');
    }

works without warning, Thanks everyone

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T06:15:32+00:00Added an answer on June 11, 2026 at 6:15 am

    Use DateTime to do the comparison:

    $format = 'D, d M Y H:i:s O';
    $tz = new DateTimeZone( 'America/New_York');
    
    // Create two date objects from the time strings
    $pubDate  = DateTime::createFromFormat( $format, 'Tue, 11 Sep 2012 17:38:09 GMT', $tz);
    $postDate = DateTime::createFromFormat( $format, 'Tue, 11 Sep 2012 17:38:09 GMT', $tz);
    
    // Compute the difference between the two timestamps
    $diff = $pubDate->diff( $postDate);
    
    // If the total number of days is > 0, or the number of hours > 0, or the number of minutes > 10, then its an invalid timestamp.
    if( $diff->format( '%a') > 0 || $diff->format( '%h') > 0 || $diff->format( '%i') > 10) {
        die( 'The timestamps differ by more than 10 minutes');
    }
    

    You can play around with it and see it working in this demo.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have looked at the different questions regarding this issue, but couldn't find anything
I have looked at this page for some time now. Amazing, really. But I
I have looked around on Google and StackOverflow for the answer to this question,
I am re-hashing this question because I have looked at over 50 threads in
Hi and thanks for looking at this newbi question. I have looked for anykind
I have looked at this a bunch of different ways and with what little
I have looked and I could not find this question before, and it surprises
I am new so this is probably simple but I have looked everywhere and
Note: A have asked this question at the Superuser community first , but since
I've looked for similar questions, but this must have been asked before. Either way,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.