I want to convert this string "2018-11-13T9:24" to Date in my js Code
var date = new Date('2018-11-13T9:24');
app.dialog.alert(date, 'Date');
but in my alert, I see:
I don't have any problem with time after 10 like '2018-11-13T11:24'
Related
I can't get it to parse. I always get Invalid Date.
My Input date '2022-08-15 19:44:15.173'
My date format string 'yyyy/MM/dd HH:mm:ss:SSS'
My reference date value "2022-08-15T21:36:12.027Z" I'm using new Date().
my call - parse(inputDate, 'yyyy/MM/dd HH:mm:ss:SSS', new Date());
Is the issue with my reference date?
I know how to get the month of current page but I want to know how to get the month of current page in string in fscalender please help me I'm new to iOS.
let values = Calendar.current.dateComponents([Calendar.Component.month, Calendar.Component.year], from: self.fscalenderobj.currentPage)
var CURRENT_MONTH = values.month
it's in integer form like in today month -> 5 ,I want it in name like May.
It's pretty simple.
let monthSymbols = Calendar.current.shortMonthSymbols (or monthSymbols dependeing upon what you need)
You can refer this
https://developer.apple.com/documentation/foundation/calendar/2293753-shortmonthsymbols
I am building my first ReactNative iOS and Android app. I am an iOS coder with Swift and Obj-C. How do I fetch the current date using ReactNative.
Shall I use Native Modules or is there an ReactNative API from which I can get this data ?
The JavaScript runtime in React Native has access to date information just like any other environment. As such, simply:
new Date()
... will give you the current date. Here's the MDN on working with dates in JS.
If you want a good JS library to make working with dates even easier, check out MomentJS.
I used {new Date()} was generating Invariant Violation: Objects are not valid error the following date function worked for me.
const getCurrentDate=()=>{
var date = new Date().getDate();
var month = new Date().getMonth() + 1;
var year = new Date().getFullYear();
//Alert.alert(date + '-' + month + '-' + year);
// You can turn it in to your desired format
return date + '-' + month + '-' + year;//format: d-m-y;
}
For more info https://reactnativecode.com/get-current-date-react-native-android-ios-example
It works for ios as well.
I think this should work;
new Date().toLocaleString()
It will return date and time formatted in your local format (usually in the below format);
"6/22/2021, 2:59:00 PM"
if you get currentmilisec date use + new Date() and if get current use new Date()
I hope Help to you
GoodLuk
I have been trying to setup local notifications with Titanium mobile for iOS, using a custom date time, but its not working with custom date time. What I am trying is
var notification = Ti.App.iOS.scheduleLocalNotification({
alertBody:"Dummy text",
alertAction:"Re-Launch!",
userInfo:{"hello":"world"},
date: new Date("2015-03-22 01:45")
});
However when I use this for date, It works.
date: new Date(new Date.getTime()+8000)//Current date time + 8 secs after.
What should I do to make this work.
date: new Date("2015-03-22 01:45")
Thanks.
The date string you are passing to the constructor is not valid.
You could use something like:
date: new Date("1/20/2015 00:00:00")
Where the format is MM/DD/YYYY HH:MM:SS
I am trying to get the timezone from native calendar using the following code but i am getting the timezone has Asia/Calcutta instead of just 'IST'
Calendar calendarLocal = Calendar.getInstance();
// fetches time zone
TimeZone timeZone = calendarLocal.getTimeZone();
System.out.println("Time Zone getAvailableIDs() --->"+timeZone.getAvailableIDs());
String[] x=timeZone.getAvailableIDs();
for(int i=0;i<x.length;i++){
System.out.println("Time Zone IDs-->"+x[i]);
}
System.out.println("Time Zone ID--->"+timeZone.getID());
System.out.println(" Calender Default-------->>>"+timeZone.getDefault());
System.out.println("Time Zone --->"+timeZone.getTimeZone(timeZone.getID()));
Here TimeZone is Asia/Calcutta i need it to print IST
BlackBerry Java doesn't give you the time zone short codes, at least not reliably (it only gaurantees to know about the "GMT" code). You can see my answer here for information about how to code a mapping between strings like "Asia/Calcutta" and "IST". (my method mapTimeZoneCodes() in that example)
I provide a template method for setting up the mapping, and a link to this article on Desktop Java, which seems to have a pretty complete list of the time zone codes, and how to map codes to the long Java time zone strings.
It will be boring work to copy the strings into my template, but once you have it, you'll be able to easily lookup the short code based on the long name:
String longName = timeZone.toString();
String shortCode = (String)_timeZones.get(longName);