how to transform Carbon date into m-d-y format? (opposite) - datetime

I've this date format: November 12, 2018 and I want to transform it into (m-d-y) format to be able to insert it into DB (as dynamic data..). Any help will be appreciated.
checked most of the answers, all are talking how to convert from (d-m-y) into Carbon (human format) .. I couldn't find something for this.

Using 'Carbon', this will return the desired date format which is: 2021-12-27
Carbon::parse('December 27, 2021')->format('Y-m-d');
note: I'm using Laravel framework.

Related

How to change UK date format in LogicApp

Im trying to convert a U.K. input date (dd-MM-yyyy) to format (yyyy-MM-dd)
I tried
"#formatDateTime('15-03-2019','yyyy-MM-dd')" ==> Error
but got error:
'In function 'convertTimeZone', the value provided
for date time string '15-03-2019' was not valid. The datetime
string must match ISO 8601 format.'
How do I go about converting this input date? The input format is (dd-MM-yyyy) and cannot be changed.
I can easily convert from (MM-dd-yyyy) as shown below, but im not able to convert from (dd-MM-yyyy)
"#formatDateTime('03-15-2019','yyyy-MM-dd')" ==> OK
Date and time functions provided by azure logic app cannot recognize the timestamp in dd-MM-yyyy format.
After my research, there is no existing function that can directly solve this problem, but you can use substring and concat to deal with this problem.
The workflow of the logic app looks like this:
The expression of the formatDataTime:
formatDateTime(concat(substring(<your-date-string>,6,4),'-',substring(<your-date-string>,3,2),'-',substring(<your-date-string>,0,2)),'yyyy-MM-dd')

How to get current date in pega, YY-mm-dd format

I want to get current system date in pega (Year-Month-Date)
YYYY-mm-dd
format.
Using
#(Pega-RULES:DateTime).getCurrentDateStamp()
can get current system date in YYYY-mm-dd(Year-Month-Date) format.
The below, assigned to a Text property, gives date in format yyyyMMdd:
#(Pega-RULES:DateTime).getCurrentDateStamp()
Adjusting solution given here as below, would give the desired format yyyy-MM-dd:
#FormatDateTime(#CurrentDateTime(),"yyyy-MM-dd","America/NewYork","en_US")
Tested on Pega Personal Edition 8.6.0 using Operator with Default locale "en_US" and Time zone America/New_York.
Use this function
#FormatDateTime(#CurrentDateTime(),"MM/dd/yyyy","America/NewYork","en_US")

How to obtain string date from xml and convert in a correct format in ax?

I am trying to obtain a date from an XML file that is in this format:
2016-10-27
however, the field I am trying to put it in is in this format:
mm/dd/yyyy
is there a code for this in dynamics ax 2012? I tried str2date but it doesn't output anything.
SOLVED: Just to let you guys know even though you are obtaining a string that has a format like mine 2016-10-27 AX automatically formats it to the default format to 10/27/2016 just input the sequence correctly. (THIS IS NOT PART OF THE ANSWER I AM JUST EXPLAINING MY FINDINGS)
You will need to use str2date(string _date, int _sequence). Specify the related format in sequence. Your desired format will be 213

Decoding flight Arrival / Departure time format

I've been using a real time flight traffic API lately and I'm stuck at formating the arrival / departure times from a json response.
They come like this:
{
"dep_schd":1426843500,
"arr_schd":1426849800,
"departure":1426844020,
"arrival":1426849221
}
It doesn't look like anything I've seen before. Any ideas on how to make these times readable?
As a bonus, I can give you how an estimated time arrival looks like:
"eta":1426849221
Thank you
Edit:
Okay guys, with a bit more research and the help from you guys I managed to convert my date to a human readable date like this:
var departure = $('#departure');
var departureDate = new Date(json.departure * 1000);
departure.html(departureDate.toUTCString());
Now what I get is something like this:
Fri, 20 Mar 2015 09:33:40 GMT
My question is how can I make it simpler? So as I can get something like this:
Fri, 20 Mar 2015 09:33
This is Unix time. The number of seconds since 01 Jan 1970, 00:00:00 UTC.
On Unix you can use functions like localtime or gmtime and strftime to convert it to a human-readable form. Most languages have similar functions for dealing with these unix timestamps.
To display it in another format, use the "get" functions on the Date object (since it looks like this is JavaScript). For example departure.getUTCHours().
A better solution though is to use a library like moment.js to format the date easily:
var mDeparture = new moment(departureDate);
departure.html(mDeparture.format('YYYY-mm-dd'));
The format which your are displaying is called Epoch and it is then converted into human readable format.Here is a online site where u can get this in readable format http://www.epochconverter.com/
But you didn't mention in which language you want to convert , every language as methods to convert this in human readable and then you have to pick which info you want from it.

SAS datetime format YYYY-mm-dd HH:ii

I am trying to display a datetime in the format yyyy-mm-dd hh:mm (e.g. 2012-12-31 23:59)
In PHP I would normally use the format YYYY-mm-dd HH:ii to get what I want. I have been looking through the SAS knowledge base and the closest I can get is E8601DTw.d which provides 2008-09-15T15:53:00 which includes seconds as well as a "T" where I'd like a space.
Is there a format to do what I'd like? If not, is there a way to create my own? I don't know that much SAS myself I'm just trying to modify an existing system. Any help is appreciated.
If the standard datetime formats provided do not meet your requirements you can create a new format:
PROC FORMAT;
picture MyMSdt other='%0Y-%0m-%0d %0H:%0M' (datatype=datetime);
RUN;
DATA TEST;
mydatetime='25nov2009 14:44:56'dt;
format newdt MyMSdt.;
newdt=mydatetime;
put mydatetime= newdt=;
RUN;
Taken from this example that you can easily customize.

Resources