T O P I C R E V I E W |
bobby131313 |
Posted - 13 February 2012 : 11:25:35 How can I do that?
YYYY-MM-DDTHH:MM:SS.SSSZ (e.g., 2004-08-04T19:09:02.768Z)
Everything I Google is trying to get to the opposite... end user friendly.
TIA. |
8 L A T E S T R E P L I E S (Newest First) |
bobby131313 |
Posted - 15 February 2012 : 10:25:37 quote: What exactly are you trying to do?
I'm working with the eBay API and caching the returned results. This works great except when I use the "Auctions ending Soonest" sort. Since I'm caching, I get a ton of people clicking on links to auctions that are over. Now eBay lets me specify in the call a time (in the format above) that auctions must end after based on GMT time. So if I send the timestamp 4 hours in the future, then cache for 3 1/2 hours, that gives the user 30 minutes to be on the page clicking links before there's any chance of clicking on an ended listing. |
HuwR |
Posted - 15 February 2012 : 10:11:50 asp.net is very different to classic ASP, you can't use both together (well not easily anyway) the biggest problem with classic asp is that it doesn't reaally know anything about datetime other than the one the system uses, so you either have to interrogate the registry as in carefrees example (really not a good idea to allow websites access to the registry) or there are functions you can use in javascript which may help.
What exactly are you trying to do?
the code below will give you the correct UTC time for your server
you could capture this in a hidden formfield and then use normal string parsing to get the date into the format you want and/or workout the timezone diff etc. |
bobby131313 |
Posted - 15 February 2012 : 09:43:12 Thanks CareFree!
quote: what exactly isn't working?
There's a nut loose somewhere between my chair and the monitor. The problem is I know absolutely zero about ASP.Net. That type code is posted everywhere on the net, the reply is always "Thanks worked like a charm!" or something similar. But I have no idea how to use it (like set the value in a variable), typical asp I'm used to doesn't seem to work. How do I use that code to set the resulting string in a variable? Does the file ext have to be .aspx? My CP does say that ASP.Net version 2 is installed. This code would be awesome to get working because I want different padding on different pages and this would be very easy to change.
Carefree, your code gets the correct GMT time great, but I *think* I'm going to have my the same original problem. I need to be able to add an amount of time to it, without having to deal with it flipping past midnight and changing the day... or even the month and year for that matter. |
HuwR |
Posted - 15 February 2012 : 03:05:37 DateTime.UtcNow.AddMinutes(20).ToString("yyyy-MM-ddTHH:mm:ssZ")
should work fine in .Net what exactly isn't working? |
Carefree |
Posted - 15 February 2012 : 01:53:50 Here you go, to get GMT:
|
Doug G |
Posted - 14 February 2012 : 21:36:13 Is this windows? If yes, I have no idea. If linux, review man date which you can use to get just about any date format you want to a string.
|
bobby131313 |
Posted - 14 February 2012 : 20:34:13 bleh.... this is working but sloppy. What I really need is GMT time, then be able add time to it if I want, and get it in the format above. I belive I could use asp.net too, if anyone has any ideas...
I've come across some code like this...
DateTime.UtcNow.AddMinutes(20).ToString("yyyy-MM-ddTHH:mm:ssZ")
while Googling, but I'm kinda lost and can't get it working. |
bobby131313 |
Posted - 13 February 2012 : 12:55:02 Hmm... Not elegant, but it works...
intYear = Year(Now)
intMonth = Month(Now)
If intMonth < 10 Then intMonth = "0" & intMonth
intDay = Day(Now)
If intDay < 10 Then intDay = "0" & intDay
intHour = Hour(Now)
If intHour < 10 Then intHour = "0" & intHour
intMinute = Minute(Now)
If intMinute < 10 Then intMinute = "0" & intMinute
intSecond = Second(Now)
If intSecond < 10 Then intSecond = "0" & intSecond
strTimePadding = intYear & "-" & intMonth & "-" & intDay & "T" & intHour & ":" & intMinute & ":" & intSecond & ".000Z"
|