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

  • Home
  • SEARCH
  • 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 6940537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:45:55+00:00 2026-05-27T12:45:55+00:00

I have a very large txt file javascript array – too big for me

  • 0

I have a very large txt file javascript array – too big for me to go and edit each entry separately. It looks like this:

["12/1/2011 00:00",15848],["12/1/2011 01:00",15108],["12/1/2011 02:00",14643],["12/1/2011 03:00",14265], &c.

How can I pass this file through PHP to change all the dates and write a new file? I’m thinking I need to use strptime() or strtotime() but I’m not sure how to proceed.

The date format is Month/Day/Year.

EDIT: I ended up recreating the array from a CSV file. Here’s the code I used in case anyone’s interested. Thanks for the help.

$handle = fopen("stuff.csv", "r");

while(($data = fgetcsv($handle, ",")) !== FALSE) {
    echo "[" . strtotime($data[0]) . ", " . $data[1] . "],<br />";
}
  • 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-27T12:45:55+00:00Added an answer on May 27, 2026 at 12:45 pm

    Match all the dates in the string with a regular expression, then use strtotime() on the results:

    $str = '["12/1/2011 00:00",15848],["12/1/2011 01:00",15108],["12/1/2011 02:00",14643],["12/1/2011 03:00",14265]';
    $p = '#(\d+/\d+/\d{4}\s\d{2}:\d{2})#';
    preg_match_all($p, $str, $matches);
    
    foreach ($matches[1] as $m) {
      echo strtotime($m) . "\n";
    }
    

    UPDATE: Just realized you said your data is in a javascript array. You can handle this easily in JS as well:

    var new_times = [];
    var times = [["12/1/2011 00:00",15848],["12/1/2011 01:00",15108],["12/1/2011 02:00",14643],["12/1/2011 03:00",14265]];
    
    for(i=0; i < times.length; i++) {
      var d = new Date(times[i][0]);
      var new_arr = [(d.getTime() / 1000), times[i][1]];
      new_times.push(new_arr);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very large file that looks like this (see below). I have
I have multiple (many) files; each very large: file0.txt file1.txt file2.txt I do not
I have this large (and oddly formatted txt file) from the USDA's website. It
I have a very large graph stored in a single dimensional array (about 1.1
I have a large dictionary file, dic.txt (its actually the SOWPODS ) with one
I have a very large number of files with very similar names: row1col1.txt, row1col2.txt,
I have a very large code base that contains extensive unit tests (using CppUnit).
We have some very large data files (5 gig to 1TB) where we need
I have a very large (~6GB) SVN repository, for which I've written a batch
I have a very large codebase (read: thousands of modules) that has code shared

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.