I am doing php parsing and getting date like Thu 1 Dec and I want to store it in database and my date column in database is of DATE type, so when I store this in database, it inserts 0000-00-00 because of improper format. How can I convert it into proper format?
Asked
Active
Viewed 55 times
0
-
1Well you need a year to start with – moffeltje Dec 28 '16 at 13:10
-
You may use Corcel to parse this time domain to generate what ever you want. – Shankar Thiyagaraajan Dec 28 '16 at 13:11
-
Change field type from DATE to varchar then you will be able to store any format of date in database. – user247217 Dec 28 '16 at 13:13
-
@user247217 Sure, even dates like "tomorrow" or "pink". – Álvaro González Dec 28 '16 at 13:21
-
@ÁlvaroGonzález i know this is not proper way but i can handle it on frontend using php date functions – user247217 Dec 28 '16 at 13:22
-
Please give me a hint how I can convert it proper format – Ashna Ali Dec 28 '16 at 14:24
1 Answers
0
To format the date properly, use something like this
$Date = Date('c', strtotime($Date))
The date has to be something strtotime can understand, but strtotime can understand a lot.

Erik A
- 31,639
- 12
- 42
- 67