DateFormat - Allowable formats? - basic4android

I have the following code returning the time in a 24 hour format like "13:10:23"
DateTime.DateFormat = "h:mm a"
now = DateTime.Now
t = DateTime.Time(now)
lblCurrentTime.Text = t
But I'd like to have the format in hours:minutes:seconds:milliseconds
Unfortunately, the link to the supported formats from this page is broken..
http://www.basic4ppc.com/android/wiki/index.php/DateTime
Could anyone please suggest how to use DateTime.Dateformat to return a time value to millisecond resolution?
Thank you, but I'm afraid it's still returning time in the format: "23:11:09"
Perhaps my variables are incorrect?
Sub Time_tick
Dim now As Long
Dim t As String
DateTime.DateFormat = "HH:mm:ss:SS"
now = DateTime.Now
t = DateTime.Time(now)
lblCurrentTime.Text = t
End Sub

Here is the correct link.
Try: "HH:mm:ss:SS"
Note that you should use DateTime.TimeFormat and not DateFormat.

Can you try the following ?
DateTime.DateFormat = "HH:mm:ss:SS"

Related

Format a date by reversing the position of the year, month and days

The value received from the Date Picker is in the format "02-06-2020" (formatted with mask = "DD-MM-YYYY" in q-date).
I need to convert it to "2020-06-02" format to send it to the server.
I tried the following, but I get undefined.
Example:
let myDate = "02-06-2020";
console.log(date.formatDate(myDate, "YYYY-MM-DD")) //undefined
I would appreciate suggestions for finding a solution.
Thanks.
You can use moment js.
moment(moment('13-01-2020', 'DD-MM-YYYY')).format('YYYY-MM-DD');
or
date.split("-").reverse().join("-");

Parse.com — Query with a date object in Swift

A parse object in my database has a date field. I want to use a date that the user selects as the query.
query.whereKey("dateFieldParse", equalTo: janFirst)
I'm not sure how to set up this "janFirst" field. I know it has to be somehow formatted for parse retrieval but what is this format.
I tried setting the components in an NSDate object but it doesn't seem to work.
let userCalendar = NSCalendar.currentCalendar()
let janFirstComponent = NSDateComponents()
janFirstComponent.year = 2014
janFirstComponent.month = 1
janFirstComponent.day = 1
janFirstComponent.hour = 0
janFirstComponent.minute = 0
var janFirst: NSDate = userCalendar.dateFromComponents(janFirstComponent)!
....
query.whereKey("dateFieldParse", equalTo: janFirst)
One more small thing: is the hours and seconds, and even the year, necessary for retrieval? I'm only really using the month and date.
The code for Parse and Swift still seems to be very limited and I can't seem to find anything at all for retrieving dates (+ I'm still very much a iOS/swift noob). Any help, even some general steps as to what to do would be greatly appreciated.
Thanks in advance. :)
I actually had it right, I just didn't realize timezones were an issue with Parse. It seems the timezone had to be set to "GMT" (Parse's timezone). For anyone that might face a similar issue, the wee bit of code is below.
let userCalendar = NSCalendar.currentCalendar()
let timeZone = NSTimeZone(abbreviation: "GMT")
userCalendar.timeZone = timeZone!
In your Parse data browser, make sure your parse object is set to Date and you variable is set to NSDate

how to convert time to eppoch time based on date?

I need a javascript function which should take two arguments they are date and time (i.e 9 ,10 ,18,19 etc) and it should return eppoch time for that exact date and time?
please help me?
Try something like this..
var myDate = new Date("July 1, 1978 02:30:00");
var myEpoch = myDate.getTime()/1000.0;
document.write(myEpoch);

Groovy date format for UTC with milliseconds

I'm having trouble finding a good way of formatting a UTC-time stamp with this format: yyyyMMdd-HH:mm:ss.<three additional digits>
I wasn't able to find any character that represents milliseconds/hundredths, I'm not even sure this is possible, to parse that format that is.
Ideally I'd like to use the parseToStringDate that's part of the Date library.
My plan b is to convert yyyyMMdd-HH:mm:ss to milliseconds and then add the three last digits to that number.
Use yyyyMMdd-HH:mm:ss.SSS
This will get you milliseconds as well.
Test Code:
def now = new Date()
println now.format("yyyyMMdd-HH:mm:ss.SSS", TimeZone.getTimeZone('UTC'))
I would convert it like that:
def now = new Date()
println now.format("YYYYMMdd-HH:mm:ss")
You can try this:
TimeZone.getTimeZone('UTC')
Date date = new Date()
String newdate = date.format("YYYY-MM-dd HH:mm:ss.Ms")
log.info newdate

Get date from Unix Timestamp in Metro style App

Iam reading out a Json file with a date in it.
jsonValue->GetObject()->GetNamedObject("board")->GetNamedNumber("date")
That date is saved in Unix code format:
"date":1347973494
But I need to get it in a normal format like "19.09.2012".
I cant find the right function to solve that problem.
I already tried the DateTimeFormatter class but I think that was not the correct way to make this.
So anyone knows how to change the DateTime from Unix timestamp to a normal format like "19.09.2012"?
A Unix timestamp is seconds since 1970, so add the seconds to 1970-01-01.
int unixTimestamp = 1347973494;
System::DateTime timestamp = System::DateTime(1970, 1, 1).AddSeconds(unixTimestamp);
Then format the DateTime into whatever string format you like, or use it as a DateTime.
System::String^ formatted = timestamp.ToString("dd.MM.yyyy")
I solved the problem with the Calendar class which you can find here
int unixTimestamp = (int)jsonValue->GetObject()->GetNamedNumber("date");
Windows::Globalization::Calendar^ cal = ref new Windows::Globalization::Calendar();
cal->Year = 1970;
cal->Month = 1;
cal->Day = 1;
cal->Minute = 0;
cal->Hour = 0;
cal->Second = 0;
cal->AddSeconds(unixTimestamp);
mainDate -> Text = cal->DayAsString() + ". " + cal->MonthAsString() + " " + cal->YearAsString();