leyoyo pplz
just wanted a funtion for the following ::
function getTime() -- hh:mm:ss am\pm
function getData() -- dd/mm/yyyy
i know you use the format string but how does it work exactly?
thankz guyz
date([%d %B %Y l %X])
Here another example about the time (am/pm)
function LocalTimeDisplay()
local sHour = date("%H")
local sMin = date("%M")
local sSec = date("%S")
local sExtend = ""
if tonumber(sHour) >= 00 and tonumber(sHour) < 12 then
sExtend = "am"
else
sExtend = "pm"
end
sTime = ("Hub local time - "..sHour..":"..sMin..":"..sSec..""..sExtend)
SendToAll(sBot, sTime)
end
thankz for the help once again
QuoteOriginally posted by Optimus
Here another example about the time (am/pm)
function LocalTimeDisplay()
local sHour = date("%H")
local sMin = date("%M")
local sSec = date("%S")
local sExtend = ""
if tonumber(sHour) >= 00 and tonumber(sHour) < 12 then
sExtend = "am"
else
sExtend = "pm"
end
sTime = ("Hub local time - "..sHour..":"..sMin..":"..sSec..""..sExtend)
SendToAll(sBot, sTime)
end
you got a posible bug here.
think what can happen on 11:59:59.
it can return 11:00:00.
always grab the full time and split it with strfind.
plop
thx plop here ya go :D
function LocalTimeDisplay()
local s,e,sHour,sMin,sSec = strfind(date("%T"),"(%d+)%:(%d+)%:(%d+)")
if tonumber(sHour) >= 00 and tonumber(sHour) < 12 then
sExtend = "am"
else
sExtend = "pm"
end
SendToAll(sBot, "Hub local time - "..sHour..":"..sMin..":"..sSec..""..sExtend)
end
thankz guyz =]
my end result
function getTime()
local _,_, dHour, dMin, dSec, dExtend = strfind(date("%T"),"(%d+)%:(%d+)%:(%d+)")
if tonumber(dHour) >= 00 and tonumber(dHour) < 12 then
dExtend = "am"
else
dExtend = "pm"
end
return dHour .. ":" .. dMin .. ":" .. dSec .. " " .. dExtend
end
function getDate()
return date("%d %m %y")
end
take a look @ this corayzon, that am/pm can be done in a easyer way.
%Y full year (1998)
%y year, with two digits (98) [00?99]
%m month (09) [01?12]
%B full month name (September)
%b abbreviated month name (Sep)
%d day of the month (16) [01?31]
%w weekday (3) [0?6 = Sunday?Saturday]
%A full weekday name (Wednesday)
%a abbreviated weekday name (Wed)
%H hour, using a 24-hour clock (23) [00?23]
%I hour, using a 12-hour clock (11) [01?12]
%p either "am" or "pm" (pm)
%M minute (48) [00?59]
%S second (10) [00?61]
%c date and time (09/16/98 23:48:10)
%x date (09/16/98)
%X time (23:48:10)
%% the character %
cheerz plop dude!
thats more what i was after =]
Ha thx
i don't see a reason any more to split that time up in strings. This is way faster YUPS. The stringfind was there to get the Hours and calculate the am/pm thingy. but euhh lets dump that code
date("%T %p") - will do fine now no need for the other code anymore
;)
hahaha...someone removes my harmless little joke
taripaz! :rolleyes: