473,385 Members | 1,333 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

strtotime("2007 Jul 10") fails

I'm working with dates in several formats including 'yyyy MMM dd', but
strtotime doesn't recognize this format and returns FALSE.

Is there a direct way to convert times from this format into
timestamps, other than my having to whip up a simple parsing routine?

My headache is that I use strtotime in a lot of places in a lot of
files, and I'd hate to have to add a wrapper everyplace I use it. I
wish there were a way to extend strtotime's default functionality, but
I know that would involve hacking the PHP source code.

Jul 10 '07 #1
6 1493
On Jul 10, 1:16 pm, Brian Kendig <b...@enchanter.netwrote:
I'm working with dates in several formats including 'yyyy MMM dd', but
strtotime doesn't recognize this format and returns FALSE.
Because that isn't a supported date format.
>
Is there a direct way to convert times from this format into
timestamps, other than my having to whip up a simple parsing routine?
Not really -- other than turning it into a format that is recognized.
>
My headache is that I use strtotime in a lot of places in a lot of
files, and I'd hate to have to add a wrapper everyplace I use it. I
wish there were a way to extend strtotime's default functionality, but
I know that would involve hacking the PHP source code.
You should have used a wrapper everywhere to begin with. Then this
change would be trivial.

Jul 10 '07 #2
On Jul 10, 10:16 am, Brian Kendig <b...@enchanter.netwrote:
I'm working with dates in several formats including 'yyyy MMM dd', but
strtotime doesn't recognize this format and returns FALSE.

Is there a direct way to convert times from this format into
timestamps, other than my having to whip up a simple parsing routine?

My headache is that I use strtotime in a lot of places in a lot of
files, and I'd hate to have to add a wrapper everyplace I use it. I
wish there were a way to extend strtotime's default functionality, but
I know that would involve hacking the PHP source code.
as far as I know there is no direct way. so what you need to do is cut
the first 5 char ('YYYY ') and append it to the end and then call
strtotime on the new string. You don't need to do anything to the mmm
since the strtotime will recognize it.

Jul 10 '07 #3
On Jul 10, 3:15 pm, ZeldorBlat <zeldorb...@gmail.comwrote:
On Jul 10, 1:16 pm, Brian Kendig <b...@enchanter.netwrote:
Is there a direct way to convert times from this format into
timestamps, other than my having to whip up a simple parsing routine?

Not really -- other than turning it into a format that is recognized.
Thanks for the tip - that's the approach I decided to take to avoid
this whole problem.
You should have used a wrapper everywhere to begin with. Then this
change would be trivial.
Well, I don't have THAT much foresight. I don't want to go using
wrappers for every built-in PHP function on the off chance that
someday I might want to extend their functionality. :)
Jul 10 '07 #4
On Jul 10, 4:41 pm, Brian Kendig <b...@enchanter.netwrote:
>
Well, I don't have THAT much foresight. I don't want to go using
wrappers for every built-in PHP function on the off chance that
someday I might want to extend their functionality. :)
Why not?

Jul 11 '07 #5
ZeldorBlat wrote:
On Jul 10, 4:41 pm, Brian Kendig <b...@enchanter.netwrote:
>Well, I don't have THAT much foresight. I don't want to go using
wrappers for every built-in PHP function on the off chance that
someday I might want to extend their functionality. :)

Why not?
I agree with Brian. I don't write wrappers for PHP functions. It's a
huge waste of time - both programming and processing.

In this case I would just convert the time to something strtotime()
accepts when I get it from the form.

Or, more likely, I would already have an OO approach involved and change
the class.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 11 '07 #6
On Jul 11, 8:53 am, ZeldorBlat <zeldorb...@gmail.comwrote:
On Jul 10, 4:41 pm, Brian Kendig <b...@enchanter.netwrote:
Well, I don't have THAT much foresight. I don't want to go using
wrappers for every built-in PHP function on the off chance that
someday I might want to extend their functionality. :)

Why not?
It adds overhead, it reduces readability and increases the chances for
typos (what if I made a mistake in one of my wrappers?), it's
unnecessary for the vast majority of the time, and in the rare cases
when it *would* be useful I might decide to do something differently
so I'd probably have to go edit large swaths of my code anyway.

Putting a wrapper around every built-in PHP function just in case I
might someday want to extend it is like wrapping every item in my home
in bubble wrap just in case I might someday hit my head on it.
Jul 12 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: WindAndWaves | last post by:
Hi there I have $initstartdate = date("d-m-Y"); in my code How can I get it to be date() + 1 or 7 for that matter. Because my server is in the US and I am in New Zealand, they are always...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.