Coping with dates and times is often a real headache in the planet of energetic web development. Your MySQL database has day and time data types that will be extremely powerful – and they must be employed. Using MySQL in this manner makes making date comparisons in your SQL queries a cinch. Nevertheless, quite often a developer should convert that data after coach anyone how to gathered in the database when using these data types within their tables. Mainly, simply storing a time or even time in your database this way and not doing anything for it prior to it being utilized by your web application will not have the desired result or structure. time stamp converter
Thankfully, PHP really is absolutely convenient here. PHP has this particular integrated function, strtotime (), that converts the provided particular date directly into an UNIX timestamp, which is simply a ten digit number symbolizing the amount of moments that contain elapsed since 00: 00: 00 UTC after January 1, 1970. This kind of function is very useful and it will work even though the day is prior in order to January 1st, 70 (you’ll obtain a negative number).
The code below requires a MySQL datetime and converts it right into an UNIX timestamp.
$theDate = “1992-12-31 20 or so three: 59: 59”;
$theDateTimestamp = strtotime($theDate);
// outputs “725871599”
When we have a timestamp we can do numerous cool, meaningful things with it – such as finding the quantity of time that has passed in between two timestamps. You could do that with two dynamic timestamps, like calculating age big difference between two of your own website’s users. You can also do that calculation between an energetic date and also the current time. I compute the time which has elapsed between a powerful day and the current time a whole lot, and I am going to show you some code which will make it simple for a person.