As the question states, what date format is "ds1248083197360" ? Is this a standard date format or a custom one to an application?
ds1248083197360 is 20/07/2009 (or in US format, 07/20/2009)
this might be miliseconds after 1.january year 1970 GMT 00:00. In this case, your example is 20.07.2009 10:46:37,360
It is probably the Unix time format, specified i milliseconds, meaning that it's the number of milliseconds since January 1st 1970. Wikipedia's entry on Unix time.
1248083197.360 is Monday the 20th of July 2009 09:46:37.360 GMT.
Related
I have a special case to check where a user inputs the future date and time and I need to verify if that time is valid (what do I mean by valid is explained below) considering user might be affected by daylight saving in his timezone.
For Example:
Assume the user's timezone is Adelaide, Australia. Open the link to see how timezone affects in Adelaide OR see below.
4 Oct 2020 - Daylight Saving Time Starts
When local standard time is about to reach
Sunday, 4 October 2020, 2:00:00 am clocks are turned forward 1 hour to
Sunday, 4 October 2020, 3:00:00 am local daylight time instead.
Now based on the above information my understanding is if my user selected the date-time between
4 October 2020, 2:01:00 am - 4 October 2020, 2:59:00 am
it's not valid as the hour is forwarded to 3 am.
How can I validate that in an iOS app? (Assuming i)
Basically I need to inform the user that the time selected is affected by DST and users need to select a different time.
I've looked into Date and Timezone APIs and couldn't seem to find anything which can validate this.
Thanks in advance, any help would be appreciated.
I guess the easiest way would be to convert the string (or whatever the user enters, seems you are not using the UIDatePicker) into a date and check if this is possible.
For Mid-Europe, DST is starting on March 29th, 2020, so
let df = DateFormatter()
df.locale = Locale(identifier: "de_DE")
df.timeZone = TimeZone(identifier:"Europe/Berlin")
df.dateFormat="yyyy-MM-dd hh:mm"
if let theDate = df.date(from: "2020-03-29 02:01")
{
print(theDate)
} else {
print ("Illegal date")
}
will print Illegal date.
A little more tricky is switch back to non-DST, because (in Mid-Europe) there are two possible dates for 2020-10-25 02:01 - it could mean winter or summer time with two different UTC representations.
My timezone is -4 or -5 from GMT depending on time of year. Currently it is -4.
If I use this code below, will it automatically switch when we change to -5?
select convert_timezone('America/New_York', CAST(json_extract_path_text('{"timestamp":"2019-04-16T03:30:00.704Z"}', 'timestamp') as TIMESTAMP));
Currently the line above returns a date of 2019-04-15.
But if I make this call in December (note the time has +1 hour),
will it still return a date of 2019-04-15.
select convert_timezone('America/New_York', CAST(json_extract_path_text('{"timestamp":"2019-04-16T04:30:00.704Z"}', 'timestamp') as TIMESTAMP));
In other words, will it switch between EDT and EST without intervention? Or is there a better way?
Thanks
Consider:
2019-04-16T03:30:00.704Z (UTC) in America/New_York is 2019-04-15T23:30:00.704-04:00
2019-04-16T04:30:00.704Z (UTC) in America/New_York is 2019-04-16T00:30:00.704-04:00
2019-12-16T04:30:00.704Z (UTC) in America/New_York is 2019-12-15T23:30:00.704-05:00
For US Eastern Time, a date in April will be in -4 while a date in December will be in -5. In other words, the timestamp being converted is what determines which offset to apply.
The date and time that the code executes has no relevance.
For a project I am working on I receive date and time in this format:
2015-08-16 15:00:00 UTC
yyyy-mm-dd hh-mm-ss UTC
How can I make the time display as "Saturday, August 16th 2015 at 3:30PM"? ("15:00" would be fine as well.)
And how would I make it so it checks if the date has already passed or not, so that it only displays dates that have not passed?
How would I make it so I can so that the time display as "Saturday, August 16th 2015 at 3:30PM (15:00 would be fine as well)?
Time.parse('2015-10-20 15:23 UTC').strftime('%A, %B %dth %Y at %l:%M%p')
#=> "Tuesday, October 20th 2015 at 3:23PM"
You might have to tweak it a bit to fix the suffixes (1st, 2nd, 3rd, etc)
And how would I make it so it checks if the date has already pasted or not?
You could do it like this (I'm sure there's a simpler way):
EDIT: Yes, there is a much simpler way -- check Matt's answer.
require 'time'
if Time.parse(my_date).to_i - Time.now.to_i > 0
# my_date is in the future.
end
To start, convert your string to a Time object via Time.parse(string) (APIDock).
After that you have all of the Time class to play with.
time.strftime
time.past?
I would like to convert Julian Date value to normal date. Can anyone please help me?
I have tried JulianDateToDateTime(somedouble value) but it raised exception.
Then I tried ModifiedJulianDateToDateTime(some double value) it posted a date but its totaly wrong.
For example my Julian Value is 226. It says that it must show 14 th August. But I couldnt convert it usig delphi.
Thanks
System.DateUtils.JulianDateToDateTime converts a Julian Date to a TDateTime value.
From documentation:
The Julian date is the number of days, including fractional days, since 4713 BC January 1, Greenwich noon.
And for System.DateUtils.ModifiedJulianDateToDateTime:
The modified Julian date is the number of days, including fractional days, since Greenwich midnight on November 17, 1858. Modified Julian dates are based on Julian dates, but adjusted to use midnight rather than noon as a starting point and they use a more recent date as a starting point.
So you have to enter a Julian Date based on either of those starting points.
You can use the reverse functions to get a correct Julian Date: DateTimeToJulianDate/DateTimeToModifiedJulianDate.
In comments it seems as the date you have is the day number of a certain year (sometimes referred to as the Julian Day in meteorological data logging systems).
Then use this:
myDT := EncodeDate(2014,1,1) + yourJulianDay - 1; // If the year is 2014
If your "Julian Date" really is "Julian Day" (ie. the number of days into a given year, a.k.a. Ordinal Date), then you can use the following function to convert it to a TDate (you specify the year the Julian Day should be considered to be in):
uses DateUtils;
FUNCTION JulianDay(Year,Day : Cardinal) : TDate;
BEGIN
Result:=IncDay(EncodeDate(Year,1,1),PRED(Day))
END;
This will return August 14th for JulianDay(2014,226)
I have to analyze a database coming from an iOS app, containing timestamps of the form
413033364.146713
or
413030924.054397
Unfortunately, it doesn't look like any format I know. Does anyone recognize it ?
If you are more curious about the reason for that: NSDate's reference is a "time value relative to an absolute reference dateāthe first instant of 1 January 2001, GMT."
Source: Apple's NSDate Class Reference
we can only guess because we don't know how the timestamp was created.
But
NSDate *d = [NSDate dateWithTimeIntervalSinceReferenceDate:413033364.146713];
NSLog(#"%#", d);
produces 2014-02-02 11:29:24 +0000, which is today.
If that is what you expect, then your timestamp is the number of
seconds since 1 January 2001, GMT.