Let me know if any parts need clarifying. Sorry for the messiness - currently in the middle of a lot of university work. note that days is now the total days, so two years would be around 730 days. cs = diffSeconds - Whatever's left is seconds Parts.mins = math.floor( diffSeconds / MIN ) - Get minutesĭiffSeconds = diffSeconds - parts.mins * MIN Create a Countdown Timer that counts down in seconds, minutes, hours and days to any date. Parts.hours = math.floor( diffSeconds / HOUR ) - Get hoursĭiffSeconds = diffSeconds - parts.hours * HOUR Feb 27th, 2021 5,519 0 Never Add comment Not a member of Pastebin yet Sign Up, it unlocks many cool features Lua 0.80 KB None 0 0 raw download clone embed print report local RunService game: GetService ('RunService') local TIMERBINDINGNAME 'Timer' local label script. Parts.days = math.floor( diffSeconds / DAY ) - Get daysĭiffSeconds = diffSeconds - parts.days * DAY If you’re expecting it to be over a year I’d probably do the division manually, which would look like this: local MIN = 60 year part of the response from os.date, though this method begins to produce inaccuracies if the year is a leap year. If your countdown will span years, you’d also need to account for the. Print( ( 'There are %i days, %i hours, %i minutes and %i seconds until 12:00 BST on 20 April 2020!' ):format( countdown.yday, countdown.hour, countdown.min, c ) ) here you would update a GUI or whatever it is you need to do os.clock () would be better as it’s the most accurate timer in roblox down to the microsecond, ive even seen it go down to 100. All the function does is turn a time in seconds and milliseconds then makes it into the format mins:seconds:mils as the OP requested. Local countdown = os.date( '!*t', diffSeconds ) - The first argument is important to say we're working in UTC so no offsets get applied DateTime.now () is what you need for precision of time down to the millisecond. Local diffSeconds = TARGET_TIME - os.time() In your code you would then find the current timestamp (again, in UTC) and calculate the difference: local TARGET_TIME = 1587380400 - 12:00 on 20 April 2020 BST This is always in UTC/GMT in seconds since 1 January 1970, so this is technically 11:00 on the 20 April 2020 in UTC due to the timezone difference with daylight savings. The timestamp 1587380400 is provided as the Epoch timestamp. Using the website I linked to, I enter the time in my local format, and select Local time for the timezone: Let’s take the example of a countdown to 20 April 2020, at 12:00 (midday) BST (my local timezone right now). A little timer in the bottom left corner of the screen will show how much double experience time you have remaining, and this pauses when you exit the game so you don't have to worry about using it all up before you finish a session, as it will be happily waiting for you next time you log in.Sure! There is also the built-in function os.date which can be given a time argument to save you having to do the division by 60 and 24 yourself. Do also note that the double XP codes will stack, so if you redeem three separate 20 minutes codes, for example, then you'll have an hour of 2x XP to use.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |