Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]

show days of the week
Started by jjrey95 Apr 19 2019 05:59 PM

2 replies to this topic
date os.date week
[TOPIC: post.html]


[GLOBAL: userInfoPane.html]
  • Observer

  • 29 posts
  • Corona SDK


I have a question about how to show the days of the week according to the day I am. That is, if today is Friday the 19th, when I display a list, it shows me the following: Saturday 20, Sunday 21, Monday 22, Tuesday 23. Thank you very much

[TOPIC: post.html]

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 838 posts
  • Corona SDK

Good to you as well! (couldn't resist)

With questions like this, it is a good practice to try googling them first. If you search for "Corona SDK get date" one of the first links you find is https://docs.coronalabs.com/api/library/os/date.html and you'll find your answers there. This is, however, also a Lua question, so you could also just google for "lua date" and you'd find the answers as well.

There are several ways of showing weekday name and number, the easiest perhaps being:

local date = os.date( "%A %d" ) -- %A = weekday name, %d = day of month as a number
print( date )

If you want to create a list that expands into the future, you could use the table method and add a simple if else piece for naming the dates.

[TOPIC: post.html]

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,913 posts
  • Enterprise

Can you share the code you're working with and what timezone you're in?



Also tagged with one or more of these keywords: date, os.date, week