0

Using the code below it outputs the following value: 04/10/2019 which is due to the server being set to UK date time settings. However google is reading this date as 10 April 19. So I need to convert it to ISO8601 formate, ie 10/04/2019

Dim FutureDate, TodaysDate
FutureDate = FormatDateTime(Now(),1)
TodaysDate = DateAdd("m", 0, FutureDate)
FutureDate = DateAdd("d", +100, TodaysDate)


"priceValidUntil": "<%= FutureDate %>",
user692942
  • 16,398
  • 7
  • 76
  • 175
  • `FormatDateTime()` is designed to display a string format of a `Date` object, using that as input for functions like `DateAdd()` isn't recommended. Stick to actual date values such as `Now()`, `CDate()`, `DateValue()`, `DateSerial()` etc. Formatting should only be thought about once the date calculations have been completed. – user692942 Jun 26 '19 at 10:16
  • `Response.LCID = 1033` – Adam Jun 26 '19 at 10:22
  • @Adam that will change ever outputted date on the page to US format if that's what they want, but if they're returning the dates as UK dates I'm guessing they wouldn't want that. – user692942 Jun 26 '19 at 10:31

1 Answers1

-3

I don't remember ASP supporting this, you can change the format between long date, short date, ... but not to ISO8601

I used something like this to do it (string split and concat):

d = split(FutureDate,"/")
future_iso = d(1) & "/" & d(0) & "/" & d(2)
Pablo Martinez
  • 2,172
  • 1
  • 23
  • 27
  • That approach is dangerous because it makes the assumption that the server regional settings will always be in a US format *(mm/dd/yyyy)*. VBScript already has functions for manipulating the format of various data/time components - See [Format current date and time in VBScript](//stackoverflow.com/a/22575530), you'll realise that you can make whatever format you wish, just use the functions and build the string. – user692942 Jun 26 '19 at 10:12