I use datepickers a lot in my projects the date’s default to the American YYYY-MM-DD format so they store in the database, the trouble is my clients are UK based so it’s not very readable. The datepickers let you set the format you want so I use DD-MM-YYYY.
That’s great until it needs to go into a MySQL database then I need the former date. As I know what the format will always be using strtotime makes it easy to convert like this:
$date = '26-07-2016'; echo date("Y-m-d",strtotime($date));
Using date specify the format desired then pass in strtotime with the date to be formatted.
This is a very easy method, works with times too.
For the past 12 years, I’ve been developing applications for the web using mostly PHP. I do this for a living and love what I do as every day there is something new and exciting to learn.
In my spare time, the web development community is a big part of my life. Whether managing online programming groups and blogs or attending a conference, I find keeping involved helps me stay up to date. This is also my chance to give back to the community that helped me get started, a place I am proud to be apart of.
Besides programming I love spending time with friends and family and can often be found together going out catching the latest movie, staying in playing games on the sofa or planning a trip to someplace I’ve never been before.