Jump to content

string.format


1LoL1

Recommended Posts

Hello, can anyone help me how i can use in this code string.format?

i mean 01:01:01 not 1:1:1 please can anyone help me?

dbExec( database, "INSERT INTO TEST ( Data, Data2, Data3, Data4 ) VALUES ( ?, ?, ?, ?)", data, data2, "["..day.."/"..month.."/"..year.."]", "["..hour..":"..min..":"..sec.."]") 

Edited by Guest
Link to comment
function getDateTimeString( day, month, year, hour, minute, second ) 
    return ( "%04d-%02d-%02d %02d:%02d:%02d" ):format( year or 0, month or 0, day or 0, hour or 0, minute or 0, second or 0 ) 
end 

So technically you can just modify that to your needs like so:

function getDateTimeString( day, month, year, hour, minute, second ) 
    return ( "[%02d/%02d/%04d]" ):format( year or 0, month or 0, day or 0 ), ( "[%02d:%02d:%02d]" ):format( hour or 0, minute or 0, second or 0 ) 
end 
local dateString, timeString = getDateTimeString( ... ) 

Link to comment
function getDateTimeString( day, month, year, hour, minute, second ) 
    return ( "%04d-%02d-%02d %02d:%02d:%02d" ):format( year or 0, month or 0, day or 0, hour or 0, minute or 0, second or 0 ) 
end 

So technically you can just modify that to your needs like so:

function getDateTimeString( day, month, year, hour, minute, second ) 
    return ( "[%02d/%02d/%04d]" ):format( year or 0, month or 0, day or 0 ), ( "[%02d:%02d:%02d]" ):format( hour or 0, minute or 0, second or 0 ) 
end 
local dateString, timeString = getDateTimeString( ... ) 

Thanks but i don't know how i can use in my code..

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...