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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:06:46+00:00 2026-05-30T05:06:46+00:00

I have some elements that are nil. The returned elements are in a timestamp

  • 0

I have some elements that are nil. The returned elements are in a timestamp and I want to turn all the nil elements to a current date using getdate(). I’m sorry if im not using the right terminology or asking the right questions, feel free to edit if you understand.

Here is XML:

<tickets type="array" count="2">
  <ticket>
    <solved-at type="datetime">2012-02-20T17:58:34-05:00</solved-at>
  </ticket>
  <ticket>
    <solved-at type="datetime" nil="true"/>
  </ticket>
</tickets>

The php:

    $xml = new SimpleXMLElement($result);
    $solved_at = $xml->xpath('ticket/solved-at');
    ... array
    echo "Ticket time solved at:" . $solved_at[$i]. "<br/>";

The returned:

Ticket time solved at:2012-02-20T17:58:34-5:00<br/>
Ticket time solved at:

I’d like to return the current datetime in UNIX for the null amounts in the xml, any ideas? I have tried the below but to no avail, I get same results as above:

if (is_null($solved_at[$i])) {
        $solved_at = getdate(); }
  • 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-30T05:06:47+00:00Added an answer on May 30, 2026 at 5:06 am

    Try this.

    $xml = simplexml_load_file("solved.xml");
    $solved_at = $xml->xpath('ticket/solved-at');
    
    foreach($solved_at as $solved) {
        if ($solved['nil']) { 
          $r = date('Y-m-d h:i:s a', time()); //getdate(); 
        }
        echo "Ticket time solved at:" . $r. "<br/>";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some elements and I'm using some jQuery plugins. I want to see
I have a 100 classes that have some similar elements and some unique. I've
I have created some functional categories that I use to show/hide markup elements. However,
I have a setup function that runs onload to add some behaviours to elements.
i have several common elements (components), that will generate some html. it seems my
I have a list of html elements that have some text. I need to
I have some elements that, upon hover, toggle the display (none/block) of a child
In my WebView , I have some block elements that have a background color
I have some elements that when clicked will fire some action and select the
I use NSXMLParser but i have some elements that they have the same name.

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.