Re: [Vala] Date format



Hi:

> Also, what
> I really want is the date in the format "March 5, 2018", not "03/05/18", > but it seems that only %c does that, but adds a lot of extra data that I
> don't want like the time zone.

As Christian Hergert suggests, DateTime is very useful. This works for me:

void main () {
    var date = new DateTime.now_local();
    print (date.format("%B %e, %Y"));
}

That prints March 28, 2018 today. There are a whole load of formatting

Yes, but the problem is that, in Spain, we use the opposite format: we write first the day's number, then the month's name, and finally the year, so I need to know if in my current locale I have to "%B %e, %Y", or "%e %B %Y" (without the comma), and so on... That's my problem. Using '%c' does that, but adds a lot of extra information that I don't want, like the timezone.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]