How to convert dates of this kind to month-day-year format? - date

I have to convert the following date format to m-d-Y format. How can I achieve it?
$date='Thu, 20 Jun 2013 09:09:52 UTC' and what I am suppose to pass in query is 6-20-2013
Please let me know a few quick tricks.
Thanks

date('m-d-Y', strtotime('Thu, 20 Jun 2013 09:09:52 UTC'))

Related

Transform string format whith month into timestamp in datastage

I want transform the string
Thu, 21 Jan 2021 09:48:38 +0100
in timestamp format "%yyyy-%mm-%dd %hh.%nn.%ss.6"
how to do?
Thank you
Check out the StringToTimestamp function and the other type conversion functions in DataStage.
You could also work with string manipulation first.
Note that you have not provided the information about the fraction of the second yet.

How to get RFC1123 Date format for current date time using XSLT 2.0

I am trying to retrieve current date time in RFC1123 date format in XSLT.
has anybody tried this using XSL2.0?
I have seen code for converting various date times based on zone in XSLT2.0 and to format in specific date time format such yyyy/mm/dd or YYYY:MM:DDTHH:MM:SS.0Z, but couldnt find a way to format it to show like this
Tue, 09 Jul 2019 20:34:29 GMT
concat(date:add('1970-01-01T00:00:00',concat('PT',floor(dp:time-value() div 1000),'S')),':',dp:time-value() mod 1000)
This returns in GMT format like this 2019-07-09T21:01:26:547
How to format it for - Tue, 09 Jul 2019 20:34:29 GMT using XSLT2.0?
Use current-dateTime() to get the current date and time and then use format-dateTime to format it as needed, see the spec https://www.w3.org/TR/xslt20/#function-format-dateTime on details: a picture string
'[FNn,*-3], [D01] [MNn] [H01]:[m01]:[s01] [z]'
on my machine in German summer time gives
format-dateTime(current-dateTime(), '[FNn,*-3], [D01] [MNn] [H01]:[m01]:[s01] [z]')
as
Wed, 10 July 12:01:13 GMT+02:00
This is meant as an example on the use of format-dateTime, I haven't checked the exact details of the RFC you cited to try to implement the exact requirements.
Thanks for quick reply, your solution worked using Altova XML Spy, but unfortunately it didnt worked for me in Datapower using XSLT2.0, Not sure what was wrong, may be some issue with DP firmware version.
just for other users to make this post more helpful. I tried below 2 options which didnt work for me, but might be useful for others.
using XSLT
<xsl:value-of select="java:java.time.format.DateTimeFormatter.RFC_1123_DATE_TIME.format(ZonedDateTime.now(ZoneOffset.UTC))"></xsl:value-of>
<xsl:value-of select="format-dateTime(current-dateTime(), '[FNn,*-3], [D01] [MNn] [H01]:[m01]:[s01] [z]')"/>
So I used Gateway script to get same date format which I was looking for and stored in context variable using below
var dateNeeded = new Date()).toUTCString(); //Thu, 11 Jul 2019 21:08:12 GMT

Specify date format in talend

I have used TalendDate.addDate(TalendDate.getCurrentDate(),-1,"DD") and the out put is "Wed Dec 28 23:51:27 IST 2016" .
I want it in "2016-12-28" format.
Is there any way to get that?
Thanks in advance.
This code will format it how you want it.
TalendDate.formatDate("yyyy-MM-dd",TalendDate.addDate(TalendDate.getCurrentDate(),-1,"DD"))
Be sure that in your output component, a date model is defined for this field.

conversion of Date : issue in IE

I have a date in following format..
"Tue Jun 21 10:52:32 +0000 2016"
Whenever i am trying to convert this date in
new Date("Tue Jun 21 10:52:32 +0000 2016") it is giving me an error says invalid date and i also tried moment("Tue Jun 21 10:52:32 +0000 2016") and moment(new Date("Tue Jun 21 10:52:32 +0000 2016")) it is giving the same error as invalid date in IE.
This issue is only in IE, in chrome it is working fine. I want the result in this format moment("Tue Jun 21 10:52:32 +0000 2016").format("dddd, MMMM Do YYYY, h:mm:ss a")
Please help me, Thanks in advance.
Don't use the Date object for its parsing abilities. You will find the implementations vary considerably across browsers. You're already using moment.js, so use its parser instead. You will have to be explicit about the input format.
var m = moment("Tue Jun 21 10:52:32 +0000 2016", "ddd MMM D H:mm:ss ZZ YYYY");
You can then format it however you like by passing a different format to the format function.
Also note that by default, moment will convert the above to the user's local time zone. If that's not what you intended, then consider using moment.parseZone instead. Refer to the user guide, and also to this blog article.

Tibco Businessworks Date Format

I'm trying to format a date in Tibco Businessworks 6.2.2 in the following format:
06-AUG-2015 12:11 AM
I've found the picture string on several websites for xpath that, according to those who use them, will format the date like this. I've not been able to figure out how to only get the AUG instead of AUGUST without JUNE and JULY showing up as JUN and JUL.
Here is the xpath I'm using:
format-dateTime(current-dateTime(), '[D01]-[MNn, *-3]-[Y0001] [h01]:[m01] [PN]')
Here is the output I'm getting:
06-August-2015 12:11 AM
Any and all information is greatly appreciated.
Try this :
format-dateTime(current-dateTime(), '[D01]-[MN, *-3]-[Y0001] [h01]:[m01] [PN]')
Output :
15-DEC-2015 05:56 P.M.
ref : http://www.w3.org/TR/xslt20/#date-time-examples
In Tibco BW you can use substring on the final output - for the month'AUGUST' with index from 0 to 3. But this seems to be a work around.
A better approach is to write a common process of Date formtter with JavaCode activity from Java Palette. It doesn't and need any specific jar/lib import.
new SimpleDateFormat("yyyy-MMM-dd HH:mm a").format(new Date())
have you tried MMM in stead of MNn?
I used this function. (BW 5.12)
tib:format-dateTime('dd-MMM-yyyy hh:mm a', current-dateTime())
Out
06-Jul-2017 11:34 AM