0

We've got a collection of messy data, and trying to unify it.

Lots of services let you type dates out into different formats and they correctly understand them, but cant think what the process is called, or how we could go about doing this in PHP, if there is a library that already provides this.

So we've got time and dates in an old database we've inherited, and trying to clean it up a bit, some of the formats look like

  • 9pm
  • 9:00pm
  • 25th march 2015

its a complete mix and match, does anybody know of any libraries or ways to be able to parse these into a universal format?

owenmelbz
  • 6,180
  • 16
  • 63
  • 113

1 Answers1

1

the problem here is the information you have is inconsistent! you need to normalize it some way, IT might actually be worth getting into an excel sheet and try to match the date time fields into some kind of regex and filter like that, is probably what i would do, so you can separate the different formats and tackle each format individually.

A program will have to first identify the format you're feeding it and then it will spit out whatever format you want!

you can use this strtotime() PHP with this to turn it into any format http://php.net/manual/en/function.date.php

Damian S
  • 21
  • 6
  • Yup, thats what we're trying to do get it all in 1 format, although nobody here is an excel pro and able to really do it that way, Think its going to be a long old slog – owenmelbz Jan 15 '16 at 15:19
  • there are quite a few patterns here http://regexlib.com/UserPatterns.aspx?authorId=a31a0874-118f-4550-933e-a7c575d149ae – Damian S Jan 15 '16 at 16:00