I am working on a webrequest, and the last part of it is (for exemple) :
...&cb=jQuery1702547129448580113_1468872275121
I was sure this relies to the DateTime the Get request is send to the server, and 1468872275121 indeed is 18/07/2016 20:04:35 UTC (converted from Json/Unix date format).
Ok good.
But any idea what could be the first part ?? Is it also a DateTime value ? (the request is sent when adding some item to your cart on a commercial site)
Thanks!
The default for dates in JSON is a string in RFC 3339 or IS 8601 format, like "2012-04-23T18:25:43.511Z". You will also find dates stored as a number storing either seconds or milliseconds since midnight, Jan 1st. 1970 in UTC.
A year has about 30 million seconds. Compare that with the number that you see.
Related
I am bringing in data from a DB that has times in the 12-hour format. For some reason, the code that writes to the DB is writing the time sometimes as 3:30 pm and other times as 03:30 pm. I can not control that. I can however control how I am querying the data. I am trying to get it uniform so that all times return without the 0. EG all times of 3:30 pm would return as 3:30 pm, not 03:30 pm.
I have tried date format, time format string_to_date and nothing works. IF I convert it to a 24 hours time format by using TIME_FORMAT(my_column_name,'%H:%i') it converts 2 PM to 02:00. IF I don't convert it to the 24-hour format and use TIME_FORMAT(my_column_name,'%l:%i') it ignores my request not to have a leading 0.
The intial time is stored as a MetaKey in the longtext format. The program just places the time in there as it chooses as text
How do I fix this?
I have a DateTime value stored in an SQL Server DB with a value like '2016-04-13 00:00:00.0000000'. My problem is that I want to display this value on a HTML page as is without the browser or my server adjusting for Time Zone offsets.
I make an Ajax request to get my data to an MVC controller. I can see that the value of the Date in my ViewModel is correct. When it gets to the browser depending on the machines timezone the Date is offset.
All I want is that if I have a value 2015-04-13 00:00 in my database then that exact value gets displayed on my interface regardless of timezones, locales etc.
My Ajax request returns a value like "/Date(1460502000000)/". I've tried the following conversions:
new Date(datavar);
Date(datevar)
new Date(parseInt(datevar.replace('/Date(', '')))
I've also tried using moment.js like the following:
moment.utc(datevar).format();
moment(datevar).tostring()
An several others all of which try to offset the date some way or other.
The suggested linked answer is different in that it will include the timezone offset. So a client on US Central Time a value of "/Date(1460505600000)/" will be converted to 'Tue Apr 12 2016 18:00 GMT-0500" while a client on GMT will get the same value converted to "Wed Apr 13 2016 00:00:00 GMT+0100"
In my json date is represented like this :-
"from":"2015-11-11T09:21:00.00Z"
But when it gets converted to java.sql.Timestamp it looks like this :-
2015-11-11 17:21:00.0
My timezone is Singapore . It is 8 hours ahead of UTC timezone and coincidentally the date also gets converted to 8 hours ahead of its time.
They are showing the same times, just formatted differently for the different locations. The time you are taking in is UTC/GMT. What you are viewing in your IDE is showing the local time stamp formating, but they are the same values and points in time.
If it really matters how it is displayed to you in the debugger you can use a Calendar object instead of a TimeStamp and set the locale value to be UTC and it will format them the same way, but again they are the same values.
I don't want the Timestamp in java to be different from json
It is not different, the display format is different do to the location setting but they are the same values just represented differently.
P.S. Be aware that if your server is set to a different time zone than your work station it will show a different format as well, but it again will be the same time just represented differently.
I have to convert the json date to c# datetime format
date is 3190549620000
and it orginal date format is 24jan2014 1:17pm
how can i convert this , meanwhile i followed this blog but it not worked
First, 3190549620000 is very big, causing an overflow when using the method you linked to.
3190549620 (divided by 1000, meaning the original is in milli seconds ) works better.
Secondly, if I use the method you link to to revert to a unix timestamp, I get 1390565820.
Compare
1390565820
3190549620
If I reverse the 31 in your example to 13, I get the correct date, but incorrect time. Can you verify and confirm that your input starts with 31 and not 13?
The date issue is a simple one: it seems to be 5:30 difference. What timezone are you in? My guess would be IST, so that is simply a timezone offset issue :)
It seems that your timestamp () is in UTC.
Change the code from your link to:
private static DateTime ConvertFromUnixTimestamp(double timestamp)
{
var origin = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
return origin.AddSeconds(timestamp / 1000).ToLocalTime();
}
If I use 1390549620000 instead of your 3190549620000 as input, I get your desired result.
First you need to know what is represented by that integer. Normally in a lot of services EPOCH dates are used. These EPOCH number are seconds since 1/1/1970 0:0:0, the first date in Unix. But maybe the service you are consuming is returning you ticks, or another format of date. Can you take a look at the docs??
I'm have access to a 3rd party application's database, and I see a field called "date" which stores date/time values as floating point numbers, but I'm not sure how this floating point number is mapped to a date/time. There is no documentation for this database.
Here is some sample data:
date-field actual-date-time
253507382.168744 1/12/09 6:43 PM PST
253507480.136126 1/12/09 6:44 PM PST
253508091.838982 1/12/09 6:54 PM PST
256703604.015055 2/18/09 6:33 PM PST
256704413.484674 2/18/09 6:46 PM PST
Note: I had to enter these values manually so there's a slight chance they may be off a bit. If you would like to see more data, let me know and I'll add more.
I'm hoping someone is familiar with storing dates in this format and can let me know how to get a date/time given a floating point number.
If you look at the change in the numbers over the 10 and 13 minute intervals, you'll see that it's about 60. Therefore I conclude that it's a count of the number of seconds from a base date.
I think the base date is 1/1/2000 or 1/1/2001.
Edit: The base date appears to be 1/1/2001, and the time appears to be adjusted as well - it's probably UTC with your local time offset added.
If you subtract any of the two points you'll see that the values represent the number of seconds, at microsecond accuracy. It should be easy to work out the base date where the clock "started". On Unix and related systems this is January 1st, 1970.
The timestamps are 'number of seconds elapsed since 00:00 on January 1st 2001'. It's not a common date format but at least it should be easy to work with now you know what it represents!