vardate = '01/20/2017 09:20 :35'-mm/dd/yyyy hh:mm:ss
I want to convert it to the format dd-mm-yyyy hh:mm:ss
I can get some information about How can I get guidance in the format I want?
function convertDate(vardate)
local d,m ,y,h,i,s = string.match(vardate,'(%d+)/(%d+)/(%d+) (%d+):(%d+):(%d+)')
return string.format('%s/%s/%s %s:%s:%s', y,m,d,h,i,s)
end
- -Call it this way
convertDate('01/20/2017 09:20:35')
If you need more participation, I recommend using an external library.
div>
I am retrieving the date from the database in the following format:
vardate = '01/20/2017 09:20:35 '-mm/dd/yyyy hh:mm:ss
I want to convert it to the format dd-mm-yyyy hh:mm:ss
I can get some information on how to get Do I want guidance in the format?
Date formatting in Lua is pretty simplistic. If you only need to convert it from one format to another, and the format will not change, You only need to use string.match:
function convertDate(vardate)
local d,m,y,h,i,s = string.match (vardate,'(%d+)/(%d+)/(%d+) (%d+):(%d+):(%d+)')
return string.format('%s/%s/ %s %s:%s:%s', y,m,d,h,i,s)
end
-- Call it this way
convertDate(' 01/20/2017 09:20:35')
If you need more participation, I recommend using an external library.
WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3221 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC