Jump to content

Recommended Posts

Basically I have recently been playing around with parsing a csv file. What I am looking to do at this point is simply take the date/timestamp (part of the csv file), which is in the following format:DD/MM HH:MM:SS.100th/s

For the sake of argument, lets say I have this in an array string called $csv[0] and the file has several lines that span the course of a couple hours. I wouldn't mind having to use explode() to breakup/remove the date or 100th/s IF that would make things a lot simpler.

 

So where would I start in trying to achieve this?. The result I am looking for will simply return "X Seconds". Storing this in a string variable would be a bonus, as I plan to use this to divide a separate piece of information.

 

Any examples or ideas would be great. Thank you.

 

ps:

Here is an example time from the csv file itself:

11/19 22:23:18.143

Thanks Manic Dan,

Is there any chance you could show me an example?  :shrug:

I know I may be a lil dumb. (I am very new to PHP). But I am unsure what you are saying.

 

I guess to clarify further the csv file that I using is about 5mb of text.

The first line is as follows:

11/19 22:23:18.143  SPELL_AURA_APPLIED,0x0200000002CA1862,"Chomi",0x10514,0x0200000000EB54DA,"Shasre",0x514,57330,"Horn of Winter",0x1,BUFF

and the last line is as follows:

11/19 23:18:45.018  SWING_DAMAGE,0x0200000004EF41E0,"Ponkyy",0x518,0x02000000050469BD,"Croe",0x518,1634,-1,1,0,0,0,1,nil,nil

 

It is basically the time from the server of the game (in this case WoW). I want to build a script that will be able to be used on different files. (depending on what "combat log" is uploaded). As a result the first and last time will most likely always be different.

 

 

 

More accurately, you probably want fgetcsv

 

Once you have the timestamp in a string, you need to use explode to break it into its parts.  You will have to use explode multiple times. 

 

Then, once you have the parts, you will use mktime[/code] to make a timestamp out of the parts. 

 

Once you have the timestamp representing the log file time, use time and subtract to get the difference.

 

-Dan

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.