I need to convert a TZ datetime like this:
2022-07-29T08:30:00Z
to fit the german time.
Unfortunately, Germany changes between summer and wintertime.
You can do a double Parse on the date if the date is in a string format.
Parse the date without the locale to convert it from a string and parse again with the locale.
Note that if your page locale is already set to DE, there is no need to double parse.
<cfscript>
newDate = lsParseDateTime("2022-07-29T08:30:00Z");
deDate = lsParseDateTime(newDate, "DE");
writeOutput(deDate);
</cfscript>
You can pass the third parameter to the function to format it.
https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-l/lsparsedatetime.html
Related
I have a use case where I have variable data in the following formats. When the string doesn't have time, the format object formats it with 12:00:00 => 12:00 am.
Well technically, the constructor that passes only a date IS instantiating it with a time, 12:00:00, even though it is implicit.
Example
'2021-02-12'
'2021-02-12T6:00'
'2021-02-19T18:00'
Code
const date = moment("2021-02-12");
date.format("h:mm a"); // 12:00 am
Expected
I'd like to know if that is possible that moment format the time with the empty string "" when time is not available in the data. e.g.
const date = moment("2021-02-12");
date.format("h:mm a"); // ""
how to convert a string of format'2019-09-01T02:55:10.000Z' to date in plsql?
I tried converting using to date function but it doesn't work
Try:
TO_DATE('2019-09-01T02:55:10.000Z', 'YYYY-MM-DDThh:mm:ss.fffTZD')
I want to get this output:
2018-09-02 00:00:00.000
I tried the below code:
.Cells(LRS + 1, 15).Value = Format(.Cells(LRS + 1, "A").Value, "yyyy-MM-dd hh:mm:ss.fff")
And I got:
2018-09-02 00:00:00.fff
The initial date in Excel has the following format yyyy/mm/dd, no time included. That's why the time part includes only zeros 00:00:00.000. The reason I want to include the time in the specific format is that I'm planning to import those dates into a SQL table with that format.
Is there any solution?
As you can see from the documentation fff is not recognised as a formatting token in VBA.
Helpfully, you can actually import your data into SQL without formatting it to add the time. If you import it into a datetime field the SQL engine will automatically default the time part of the field to midnight on the date you give it.
I think you can just change your format string to yyyy-MM-dd by itself.
However if you really want to do it like this, then since there's no time specified then just hard-code 000 instead of fff. The rest of the time can be similarly hard-coded, since it never varies, so you end up with yyyy-MM-dd 00:00:00.000. But as I said, I think it's a bit pointless.
After replacing the cell format with the corresponding format, it is likely that the value of the cell is imported as text, not as a value.
Sub test()
Dim s As String, s1 As String, s2 As String
'First Cell format as your "yyyy-mm-dd hh:mm:ss.000"
Range("a2").NumberFormatLocal = "yyyy-mm-dd hh:mm:ss.000"
'In vb,This format("yyyy-mm-dd hh:mm:ss.000") is not recognized.
Range("b2") = Format(Range("a2"), "yyyy-mm-dd hh:mm:ss.000")
s1 = Format(Range("a2"), "yyyy-mm-dd hh:mm:ss.000")
's1 = "2018-09-03 01:24:33.000"
'Since you format a2 cell as "yyyy-mm-dd hh:mm:ss.000" you can get data as text
Range("b2") = Range("a2").Text
s2 = Range("a2").Text
's2= "2018-09-03 01:24:33.240"
End Sub
Sheet Data
Local Window
I want to insert a Date object in mysql database, which has a Date type in the database as well. I am having problems inserting the date .
I have tried this code, but it seems codename one have a problem with it:
dateString s;
s = date.getCurrentMonth() + "/" + date.getCurrentDay() + "/" + date.getCurrentYear();
DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
Date startDate = (Date) formatter.parse(s);
Please can you tell me how to do it ?
You don't need to format it. Just use this SQL Date Object instead of Date object from java.util package.
import java.sql.Date
// Creating a date object.
Date date = new Date();
In a database, make sure the data type of attribute 'date' is selected as "Date" also, not VarChar. Simply pass this sql package Date object into the database through query. :) It will save the date in a format.
This question someone is already asking and solution is with JavaScriptConverter (.NET) but how can I convert normal date into JSON date string with java script.
For example I have a formated date "12-12-2012" and I want to get string something like this example:
/Date(1354316400000+0100)/
Icky, awful format, and clumsy slow serializer. (IMHO)
On the server, use Json.Net and its default ISO8601 formatted dates instead.
On the client, use moment.js. It will handle all of the parsing and formatting you could want.
For posterity, if you want to output this format using moment.js, you can do one of these:
moment().format("[/Date](XSSS)/"); // /Date(1198908717056)/
moment().format("[/Date](XSSSZZ)/"); // /Date(1198908717056-0700)/
s = "12-12-2012".split("-");
epoch = Date.parse(s[2] + "-" + s[0] + "-" + s[1]);
output = "/Date(" + epoch + ")/";
if you need the timezone offset, you can use .getTimezoneOffset() on the Date Object and add that to your output string.