I have this string, "Tue 19:00 PDT"

I know it's this week. How can a get a datestamp. I've tried strtotime then also stripped out the timezone text and used it in strtotime but it has not worked

    So ... I'm guessing it did something else. Do I have to guess what it is?

      Well here's what I have

              do {
                  if (strtoupper($CurrentDate->format('D')) == strtoupper($DepTimeArray[0])){
                      echo 'yes';
      
              } elseif (strtoupper(date_add($CurrentDate, date_interval_create_from_date_string('-1 day'))->format('D')) == strtoupper($DepTimeArray[0])){
                  
                  $CurrentDate = date_add($CurrentDate, date_interval_create_from_date_string('-1 day'))->format('D');
                  echo $DepTimeArray[0] . ' ' . $CurrentDate->format('D');
      
              } elseif (strtoupper(date_add($CurrentDate, date_interval_create_from_date_string('+1 day'))->format('D')) == strtoupper($DepTimeArray[0])){
                  
                  $CurrentDate = date_add($CurrentDate, date_interval_create_from_date_string('+1 day'))->format('D');
                  echo $DepTimeArray[0] . ' ' . $CurrentDate->format('D');
      
              }
             
             //echo strtoupper($CurrentDate->format('D')) . ' ' . strtoupper($DepTimeArray[0]);
          } while (strtoupper($CurrentDate->format('D')) != strtoupper($DepTimeArray[0]));
      

      $CurrentDate = 'Wed' and my ($DepTimeArray[0] = 'Tue'

      This could adjust the current date to match, why is is not working?

        The above code just endlessly looks with Wed Tue Wed Tue Wed Tue

          When you say, "I know it's this week," does that mean if it's currently Wednesday, then it's yesterday, but if it's Monday, it's tomorrow? If so, what's the break point where you look forward instead of backward? Or, is it always then next Tuesday? What if it's Tuesday now, but 23:00? (Part of the reason of asking all these questions is to help you spell out the actual algorithm needed, at least in English if not yet in PHP.)

            I'm working between two different sets of data. In data A I have the day of week and time of day. In data set B I need to pass in the actual date.

            My issue is dataset A's day of the week is always in a different timezone, I know the associated timezone and what the current day of the week is there.

            My issue when the timezone says, in Los Angeles is currently Tuesday but my server is in a location where it's Wednesday. If so I need to go back a day on my date object.

            Does that make sense?

              So the "week" and the date have nothing to do with it, and the problem is to do with timezones and the fact that the same instant is referred to by different names in different timezones (which is exactly what makes different timezones different).

              Since the timezone is specified (I don't think there's any ambiguity about "PDT" representing "Pacific Daylight Time"), then constructing the timestamp should take that into account. Then reformatting that timestamp for the local timezone would give the correct day.

              $input_string = 'Tue 19:00 PDT';
              
              $target = DateTime::createFromFormat('D H:i T', $input_string)
                  ->setTimeZone(new DateTimeZone('Pacific/Chatham'));
              
              echo $target->format('l, Y-m-d H:i:s');
              

              Or are you saying that the week is wrong in the result? If so, NogDog's questions haven't been answered (I'd sum up most of them by asking "what do you mean by 'this week'?" I can think of at least four different definitions even without considering timezones).

              a month later

              How can I add date and time to my website https://192168ips.com/ ?

                Write a Reply...