Jump to content

Difference In Time Between Timestamps


xProteuSx

Recommended Posts

I am having trouble finding the time between two timestamps. I have tried to research this, but I don't even understand this timestamp format. This is the format for the data I am given (I have no choice in this!):

 

2012-12-13T11:34:16.771Z

 

I don't even know what the T and Z stand for! .. and I can't seem to figure it out.

 

I have a second date to compare to this. For example:

 

2012-12-13T12:04:29.000Z

 

I have to figure out the difference in days, hours, minutes, and seconds.

 

There must be a php function that can return the difference, if only in seconds (I can handle it from there).

 

Any ideas? Thanks in advance!

Link to comment
Share on other sites

Man, this timestamp is ridiculous (I am a noob).

 

Here is what I have tried to do:

 

$endtime = 2012-12-13T12:36:59.000Z;

$curtime = 2012-12-13T12:12:44.723Z;

 

Find the difference (the difference should be around 25min);

 

Here is what I have tried:

 

 

$endtime = strtotime($endtime);

$curtime = strtotime($curtime);

echo date_sub($auc_endtime,$ebaytime);

 

The issue is that I get the following error:

 

Warning: date_sub() expects parameter 1 to be DateTime, integer given

 

:(

 

Should I be using date_parse?

 

The issue for me is that I have to use something lightweight. I am comparing two timestamps; one is from eBay so I have to make an API call which delays my page loading time, the other is a timestamp from a database. The whole point is to speed up the process of calculating days, hours, minutes, and seconds between these timestamps.

Link to comment
Share on other sites

Think I've got it figured out:

 

 

$auctime = date_parse($endtime);

$ebaytime = date_parse($curtime);

 

if (($auctime["month"] <= $ebaytime["month"]) && ($auctime["day"] <= $ebaytime["day"]) && ($auctime["hour"] <= $ebaytime["hour"]) && ($auctime["minute"] <= $ebaytime["minute"]) && ($auctime["second"] <= $ebaytime["second"]))

{//auction is over}

 

... seems to be getting it done.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.