• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 2.0 Convert database field YYYY-MM-DD to XF format

AndrewSimm

Active member
#1
I don't fully understand how XF2 comes up with the date number. How would I convert a field formatted as YYYY-MM-DD to the XF2 format?
 

Sim

Well-known member
#2
the long numbers are called a unix timestamp

to convert to something you can manipulate in MySQL, use the FROM_UNIXTIME function in your query

To go the other way, there is an equivalent UNIX_TIMESTAMP function - but be aware that translation between the two values is lossy in regards to timezone mapping (unixtime should generally be in GMT).

Alternatively, look at using a library like Carbon to make time format conversions and manipulation in PHP