In my application, I have some records which I need to filter based on some time parameters. To do the date comparisons, I need to convert the dates in my records (a string in the format YYYY-MM-DD), to a unix timestamp (seconds since 1970). Since I have many thousands of records, I really want to find the most efficient way to do it.
Answers to another question suggested doing it in the database (not an option here, sadly), using strtotime()
or strptime()
, but these don't feel like the most memory- and time-efficient methods, you know?
Given that I know the exact format of my input, would perhaps using some form of string manipulation (substr
, or explode
) combined with mktime
be better?
If you believe I'm being premature in my optimisation, then just humour me ok?