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 6859859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:20:09+00:00 2026-05-27T02:20:09+00:00

I have an array like the one below array( hgfh => array(s => 2011-11-28T07:00-04:00,

  • 0

I have an array like the one below

array(
    "hgfh"  => array("s" => "2011-11-28T07:00-04:00", "e" => "2011-11-29T06:59-04:00"),
    "hgfh"    => array("s" => "2011-11-29T07:00-04:00", "e" => "2011-11-30T06:59-04:00"),
    "hgfh"    => array("s" => "2011-11-30T07:00-04:00", "e" => "2011-12-01T06:59-04:00"),
    "hgfh"    => array("s" => "2011-12-01T07:00-04:00", "e" => "2011-12-02T06:59-04:00"),
    "hgf"     => array("s" => "2011-12-02T07:00-04:00", "e" => "2011-12-05T06:59-04:00"),
    "sog"     => array("s" => "2011-12-05T07:00-04:00", "e" => "2011-12-06T06:59-04:00"),
    "gfd"     => array("s" => "2011-12-06T07:00-04:00", "e" => "2011-12-07T06:59-04:00"),
    "gfd"     => array("s" => "2011-12-07T07:00-04:00", "e" => "2011-12-08T06:59-04:00"),
    "bob"  => array("s" => "2011-12-08T07:00-04:00", "e" => "2011-12-09T06:59-04:00"),
    "tree" => array("s" => "2011-12-09T07:00-04:00", "e" => "2011-12-11T23:00-04:00"),
);

For example and I need to determine if the current date("c"); is between the "s" and "e" in that array and then get the key. So it would say today is the 2011-11-30T09:50-04:00 and determine that the key is hgfh Is there any quick and dirty method to do so? I’m a bit worried about performance, so if there is a method that may be better performance wise, I would appreciate that.

  • 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-05-27T02:20:09+00:00Added an answer on May 27, 2026 at 2:20 am

    Storing dates as strings, especially when you want to do such ‘between’ comparisons, will be painful no matter what you do. You should be storing the raw PHP timestamp values that represent those times, e.g.

    array(
       'hgfh' => array('s' => 1000, 'e' => 2000)
       etc...
    )
    

    (using obviously fake timestamp values). Then it becomes a simple matter of:

    $check = strtotime('2011-11-30T09:50-04:00');
    foreach($yourarray as $key => $times) {
       if (($check >= $times[s]) && ($check <= $times[e]))
           break;
       }
    }
    echo $key;
    

    Otherwise you’re stuck converting those strings to time values every time you run the check loop, which gets expensive very fast. Always store times/dates in native formats, and convert to human-readable only as necessary.

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

Sidebar

Related Questions

I have an array which appears like the one below. I want to slice
I have HABTM and hasMany in one model like below: var $hasMany = array(
I have an array like the one below, I need to check for duplicates
I have an array that looks like the one below. I'm trying to group
I have converted an array to object data like this: <?php $myobject->data = (object)Array('zero','one','two');
I have a one-dimensional array of strings in JavaScript that I'd like to turn
i have an array like below int[] array = new array[n];// n may be
I have an array of array like below with all numeric values. I want
I have array like below, Array ( [14289] => Array ( [0] => Karthikeyan
I have a form like the one below which is posted to contacts.php ,

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.