MOMENTJS TIME FORMATTING - node.js

I have this data :
time: "2020-12-17T13:06:13.144Z"
and then I want change this data, to be like this...
"17-12-2020 13:06:13"
but when I change with this code:
{moment(time).format("DD-MM-YYYY HH:mm:ss")}
MY OUTPUT IS NOW :
"17-12-2020 20:06:13"
MY OUTPUT EXPECTATION:
"17-12-2020 13:06:13"
How can I change this format so that it matches my expectation?

Try utc() method before format:
moment(time).utc().format("DD-MM-YYYY HH:mm:ss")

You can add custom string in moment format string with [:]
Try this
{moment(time).format("["]DD-MM-YYYY HH:mm:ss["]")}

Related

Converting Issue date with download to CSV

I have a problem with the Function Module "GUI_DOWNLOAD" because of the date converting.
I want to get the date like I have it in my internal table but CSV (Excel) keeps converting it everytime.
The internal table contains the line like this: 12345678;GroupDate;2021-12-31;
The Output in the .csv-File should be "2021-12-31" but it keeps converting to "31.12.2021".
I also tried to put an ' (apostroph) before the date but the output will be '2021-12-31
Does anybode have an Idea ?
lv_conv = '2021-12-31'.
CONCATENATE TEXT-001 LV_CONV INTO LV_CONV.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = IV_PATH
TABLES
DATA_TAB = LT_FILE.
LT_FILE is a string table.
Thanks for the help.
Like Suncatcher and Sandra said the file is right but it is only the settings from excel which convert the date.
If the Output file won´t be needed for other purposes than showing the code could be something like this
CONCATENATE '=("' LV_CONV '")' INTO LV_CONV.
The csv-Output would be a date like this 1960-01-01 but in the cell the value would look like =("1960-01-01").

Python format incomplete date to YYYYMM

As a start, I am extremely new at Python.
I am receiving an Excel file where the date field is incomplete. The value displays as "190808" (YYMMDD) instead of "2019-08-08".
Part of my automation attempt is to move the file to a different location, where the file is renamed. I want to use the date field to change the file name to the file description and date (e.g. "Sales figures 201908").
The code I have only works if the date format is
str(df['Bank date'][0].strftime("%Y%m"))
I have tried dateparser with the following:
dateparser.parse(df['Bank date'][0].strftime("%Y.%m"))
The error I am receiving is 'numpy.int64' object has no attribute 'strftime'
Any help will do.
Thanks.
I modified it slightly and built my own date-string using slicing.
vOldDate = str(df['Bank date'][0])
vNewDate = '20' + vOldDate[:2] + '.' + vOldDate[2:4]
Numpy is interpreting the date as an integer. To use dateparser, you need to convert that value into a string first, then parse that string, and then format the result:
dateparser.parse(str(df['Bank date'][0])).strftime("%Y.%m")
Since the input format is expected, you should specify it to ensure you get the right date:
>>> dateparser.parse(str(190808), date_formats=['%y%m%d']).strftime("%Y.%m")
'2019.08'

Changing String into Time

I need to change String in D column(example 28/10/2018:01:51:29) into Time format.
I've tried:
Format cells and make my own formating(dd/mm/yyyy:hh:mm:ss)
Data->Text to columns
But neither worked
Your issue is the colon : between the date and the time. Try this:
=TIMEVALUE(SUBSTITUTE(D1,":"," ",1))
This will return a number, like 0.077418981 which Excel can interpret as a time if you format the cell as time. If you want to skip this step and see the time as a string, use an additional TEXT function
=TEXT(TIMEVALUE(SUBSTITUTE(D1,":"," ",1)),"hh:mm:ss")
In Czech:
=ČASHODN(DOSADIT(D1,":"," ",1))
=TEXT(ČASHODN(DOSADIT(D1,":"," ",1)),"hh:mm:ss")
You may also need to swap commas , for semi-colons ; if your regional settings require it:
=ČASHODN(DOSADIT(D1;":";" ";1))
=TEXT(ČASHODN(DOSADIT(D1;":";" ";1));"hh:mm:ss")
Translations

How to convert a String to Datetime using Dataweave Mule

I have the following string 20170912113456 and i want to convert it to this format 2017/09/12 11:34:56 using Dataweave Mule.
Any ideas about how to do it ?
I would recommend first converting your input date string into a Dataweave localdatetime object. Then you can output the date object back to a string of any format.
%dw 1.0
%output application/json
---
formattedDate: flowVars.date as :localdatetime{format: "yyyyMMddHHmmss"} as :string{format:"yyyy/mm/dd HH:mm:ss"}
If you interested in learning the inner-working check out my converting string dates to Java Date Objects in Mule tutorial, https://youtu.be/XqI_Kii9RzA
You can try few things like formatting to data and then to string based on below example.
myDate: ((payload as :string) as :date {format: "yyyyMMdd"}) as :string {format: "MM-dd-yyyy"}
For a better understanding the Date Time operations please go through below link.
https://docs.mulesoft.com/mule-user-guide/v/3.8/dataweave-operators#date-time-operations

Converting string to timestamp?

I have a xml file in which date is represented as this: "2010-07-10T14:46:00.000Z"
Im parsing it and fetching it as string.
I need to convert it into timestamp or date format to store in db. How do i do it?
Please help.
Assuming that you use PHP:
You can use the function DateTime::createFromFormat(string $format, string $time)
try the following:
$timestamp = str_ireplace(array('T', 'Z'), '', "2010-07-10T14:46:00.000Z");
$datetime = DateTime::createFromFormat('j-m-d H:i:s.u ', $timestamp);
echo $date->getTimestamp();
Please see the documentation of DateTime::createFromFormat and date() for the correct format string.
generally you need to use strptime() related functions, that come from standard C library.

Resources