Hello, I would like to know why when I print a time in javascript it show me a number “154771200…” I’m stuck on it since 3 hours already But I don’t find the way to do this, can someone help me please ?
It look like this
To get this I get my data from my SQL table then I insert it in a obj that I send to my JS script, so I have a obj,
and I search in the object thanks to this:
Server.lua
ESX.RegisterServerCallback('historique_commandes:getCommandes', function(source, cb)
local _source = source
local identifier = ESX.GetPlayerFromId(_source).identifier
local commandesData = {}
local commandesData = {
produits = {},
}
MySQL.Async.fetchAll('SELECT * FROM `nightclub_historique_commandes` WHERE date_commande > "@date"', {['@date'] = os.date("%Y-%m-%d")},
function (resultat)
if (resultat[1] ~= nil) then
for i=1, #resultat, 1 do
table.insert(commandesData.produits, {
nomProduit = resultat[i].nom_produit,
dateCommande = resultat[i].date_commande,
heureCommande = resultat[i].heure_commande
})
end
cb(commandesData)
end
end)
end)
Client.lua
ESX.TriggerServerCallback('historique_commandes:getCommandes', function( data )
SetNuiFocus(true, true)
open = true
SendNUIMessage({
action = "open",
produits = data.produits
})
end)
JS side
for (let obj of Object.keys(produits)) {
var values = [];
var i = 0;
for (let x of Object.values(produits[obj])) {
values[i] = x;
i = i + 1;
}
And I show the time with values[2], but it show what I have showed you before