Home » Development » Transform malformed MySQL dates … String to Date
I am currently working on a client project with a custom solution from someone else, that has messy date strings all over … oh what fun :)
STR_TO_DATE to the rescue! [MySQL Date functions]
’21-02-2016′, ‘%d-%m-%Y’ does the magic and tells STR_TO_DATE how to treat the string.
%a
Sun
Sat
%b
Jan
Dec
%c
0
12
%D
0th
1st
2nd
3rd
%d
00
31
%e
%f
000000
999999
%H
23
%h
01
%I
%i
59
%j
001
366
%k
%l
1
%M
January
December
%m
%p
AM
PM
%r
hh:mm:ss
%S
%s
%T
%U
53
%u
%V
%X
%v
%x
%W
Sunday
Saturday
%w
6
%Y
%y
%%
%
x
Alexander Gräf
Portfolio
Book Me
Get in touch
Live Chat
I am a full-stack developer. My expertise include:
I love programming, design and know my way around server architecture as well. I would never feel complete, with one of these missing.
I have a broad range of interests, that’s why I constantly dive into new technologies and expand my knowledge where ever required. Technologies are evolving fast and I enjoy using the latest.
Apart from that, I am a peace loving guy who tries to have people around him that think the same. I truly believe in the principle: “If you help someone, someone will help you, when you need it."