Formatting Date with JavaScript
Hello guys,
is there a way to change the date format with JavaScript? I have a library with different fields.
I hope you can help me!
Best regards
Matthias
Yes
Check below
http://www.bentedder.com/convert-a-sharepoint-datetime-field-to-a-javascript-date-object/
function convertSPDate(d) {
* A function to convert a standard SharePoint
* date/time field (YYYY-MM-DD HH:MM:SS) to a
* javascript Date() object
* Author: Ben Tedder (www.bentedder.com)
// split apart the date and time
var xDate = d.split(" ")[0];
var xTime = d.split(" ")[1];
// split apart the hour, minute, & second
var xTimeParts = xTime.split(":");
var xHour = xTimeParts[0];
var xMin = xTimeParts[1];
var xSec = xTimeParts[2];
// split apart the year, month, & day
var xDateParts = xDate.split("-");
var xYear = xDateParts[0];
var xMonth = xDateParts[1];
var xDay = xDateParts[2];
var dDate = new Date(xYear, xMonth, xDay, xHour, xMin, xSec);
return dDate;
// create a couple of variables
var startTime;
var convertedStartTime;
// a standard SPServices call
$().SPServices({
operation: "GetListItems",
webURL: myListURL,
async:false,
listName: myListName,
CAMLRowLimit: 1,
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function(i){
// set the value of startTime to standard SP date/time field
startTime = $(this).attr("ows_startTime");
// set the convertedStartTime to a true javascript date
convertedStartTime = convertSPDate(startTime);
http://spservices.codeplex.com/wikipage?title=$%28%29.SPServices.SPConvertDateToISO
http://stackoverflow.com/questions/14283106/beginner-javascript-date-conversion-from-string-to-utc-date-js-into-sharepoint
http://stackoverflow.com/questions/14742625/how-to-convert-utc-date-by-javascript
Similar Messages
-
Formatting Dates with Javascript
Hi all. I'm tryign to find the solution on the web, but have
not had much
success yet.
I"m working on a customized button my my HTMLArea script that
puts a WYSIWYG
component on my form fields to insert the date.
My code is here:
editor.insertHTML((new Date()).toString());
Which outputs this:
Fri Nov 17 2006 10:08:35 GMT-0600 (Central Standard Time)
What I'm wanting to do is to output
Friday, November 17, 2006 with no timestamp, and no reports
of GMT/CST.
Any suggestions on where I can go to look? I've been at the
W3C, but I did
not see any way to format my string.
I've tried a lot of variations in trying to format the date
witha string,
but have not had any success.
This was my last script, which erred:
var d = new Date();
d.formatDate("D, M j");
d.toString();
editor.insertHTML(d);
TIA,
Jon Parkhurst
PriivaWeb
http://priiva.net.Thanks Mick, Reviewing now.
"Mick White" <[email protected]> wrote in
message
news:ejl3t8$sho$[email protected]..
> crash wrote:
>> Hi all. I'm tryign to find the solution on the web,
but have not had
>> much success yet.
>>
>> I"m working on a customized button my my HTMLArea
script that puts a
>> WYSIWYG component on my form fields to insert the
date.
>>
>> My code is here:
>> editor.insertHTML((new Date()).toString());
>>
>> Which outputs this:
>> Fri Nov 17 2006 10:08:35 GMT-0600 (Central Standard
Time)
>>
>> What I'm wanting to do is to output
>> Friday, November 17, 2006 with no timestamp, and no
reports of GMT/CST.
>
>
http://www.mickweb.com/javascript/dates/customDate.html
>
> editor.insertHTML(customDateString());
>
>
http://www.mickweb.com/javascript/dates/date.js
>
> function customDateString() {
> var now = new
Date(),H=now.getHours(),M=now.getMinutes();
> M=M<10?"0"+M:M;
> d =
>
["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]
> [now.getDay()]+", ";
> d+=
> ["January","February","March","April","May","June",
>
"July","August","September","October","November","December"]
> [now.getMonth()]+" ";
> d+=now.getDate()+" "+now.getFullYear();
> d+=", "+H%12+":"+M+["AM","PM"][Number(H>11)||H==0];
> return d
> }
>
> Mick
>
>>
>> Any suggestions on where I can go to look? I've been
at the W3C, but I
>> did not see any way to format my string.
>> I've tried a lot of variations in trying to format
the date witha
>> string, but have not had any success.
>> This was my last script, which erred:
>>
>> var d = new Date();
>> d.formatDate("D, M j");
>> d.toString();
>>
>> editor.insertHTML(d); -
The question says it all:
What Are The Minimum Permissions In Order An User To Be Able To Access User Profile Data With JavaScript And REST API.?
In the User Profile -> Permissions there is only the option for "Full Control".Hi Nikolay,
Thanks for posting your issue, you need to set permissions on User Profiles = Read. Kindly find the below mentioned URLs to get the code and more details on this.
http://www.vrdmn.com/2013/02/sharepoint-2013-working-with-user.html
http://www.vrdmn.com/2013/07/sharepoint-2013-get-userprofile.html
http://sharepoint.stackexchange.com/questions/61714/sharepoint-2013-call-the-rest-api-from-sharepoint-hosted-app
http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2013/04/09/how-to-query-sharepoint-2013-using-rest-and-javascript.aspx
I hope this is helpful to you, mark it as Helpful.
If this works, Please mark it as Answered.
Regards,
Dharmendra Singh (MCPD-EA | MCTS)
Blog : http://sharepoint-community.net/profile/DharmendraSingh -
How to use format-date with the report parameter
Hi all,
How to use the format-date function with this tag,
<?param@begin:P_FROM_DATE?><?$P_FROM_DATE?>
this form date is coming from report parameter and is coming like this 2012/11/01 00:00:00.
So now i need this in DD-MON-YYYY fromat.I tried like this <?param@begin:P_FROM_DATE?><?$format-date:P_FROM_DATE;'DD-MON-YYYY'?>
but its giving error. Can any one pls tell how to convert it to customized date format.
thanks & Regards
Srikkanth.MIssue solved.
Ref this link
XML date Format -
Accessing Context Data with JavaScript in Adobe Form
Hi,
does anybody know, how to access a context element with javascript in an adobe form, because I have to decide which elements will be shown at the form, depending on one context value.
Thank you for your help!
Kind regards, Patrick.Hi,
First of all your WD context is mapped to the data view in the form. You can only access via scripting what is mapped to the data view and you get the values that the PDF currently has stored. The WD context and the data values in the context might differ (eg. due to editing).
Use scripting like xfa.resolveNode("xfa.dataset.data.<path.to.the.node>") to get a reference to the data node.
Then you can use the "value" property to access the data value.
Regards
Juergen Hauser -
Accessing Meta-Data with JavaScript
Hi,
In U3D one can add meta-information to the file.
Could anyone access this mata-information with JavaScript in Acrobat?
I could not find any documentation in the API or references on Internet, so far...
Thank you for every hint!
FelixFelix,<br /> Here's a hunk of code which will cycle through all the nodes, showing they're metadata. If the MD in the header is available, it will also be shown. Otherwise, no access to header info!<br /><br />//=========================================<br />console.println("scene.nodes.count = " + scene.nodes.count);<br />console.println ("----------------------------");<br />for (i=0; i<scene.nodes.count; i++)<br />{<br /> objNode = scene.nodes.getByIndex(i);<br /><br /> if (objNode == undefined)<br /> {<br /> console.println (" *** node = undefined ***\n\n");<br /> }<br /> else<br /> {<br /> console.println ("Node [" + i + "] metadataString = " + objNode.metadataString );<br /> }<br />}<br />//=========================================
-
I have 2 date fields, A and B.
What I need to do is once I tab out of A, I need to set B to A+1year-1day.
I can do this in a page process on submit with
ADD_MONTHS(:P_A, 12)-1
but I need this to be done on change of field A.
Any help appreciated
GusHi Gus,
you need to provide the date format you are using.
Add this to your FIELD A "html form element attributes":
onblur="javascript:fnc_field_b(this)"Add this to your page header:
<script>
function fnc_field_b(v_field_a){
/* Input: mm/dd/yyyy */
/* Output: dd.mm.yyyy */
/* Documentation: http://www.javascriptkata.com/2007/04/27/mastering-of-the-date-object-in-javascript/ */
/* http://programming.top54u.com/post/Javascript-Convert-String-to-Date.aspx */
/* Create date object */
var myDate = new Date(v_field_a.value);
/* Add 1 year */
myDate.setDate(myDate.getDate() + 365);
/* Create output string DD.MM.YYYY */
/* Day */
var myStr = (myDate.getDate() < 10 ? "0" + myDate.getDate().toString() : myDate.getDate().toString()) + ".";
/* Month */
myStr = myStr + (myDate.getMonth()+1 < 10 ? "0" + (myDate.getMonth()+1).toString() : (myDate.getMonth()+1).toString()) + ".";
/* Year */
myStr = myStr + myDate.getFullYear().toString();
/* Set value */
$s('P1_FIELD_B',myStr);
</script>Change the field P1_FIELD_B to the name of your field B name.
Best regards,
Tobias
Edited by: Tobias Arnhold on Mar 7, 2011 4:44 PM -
How to format date with in the file
Hi,
I have the below data in a file,
101 02100002111406893401207310900A094101xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
5200xxxxxxxxxx D18000_1 CCDXXXXXXX JUL 31201207 1140689340000001
622113010547999999999003 000333333334RE 00030137 onee SYSTEM 0140689340000001
62200000 0000999999999001 0000011111CR460 00030135 twoo system 0140689340000002
82000000040015507087000000000000000003571110D18000_1 140689340000001
Can some one tell me how to read the date which is there in line 1 which is starting with indicator 1 at position 24 to 29
in this example it is 120731
which is in YYMMDD format
I want to replace from 70 to 75 with above date + 2 as 120802 in 2nd line which starts with indicator 5
My output should look like below in a file again
101 02100002111406893401207310900A094101xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
5200xxxxxxxxxx D18000_1 CCDXXXXXXX JUL 31120802 1140689340000001
622113010547999999999003 000333333334RE 00030137 onee SYSTEM 0140689340000001
62200000 0000999999999001 0000011111CR460 00030135 twoo system 0140689340000002
82000000040015507087000000000000000003571110D18000_1 140689340000001
Can some one please tell me how to do this?
Appreciate your response.The following will help you to extract the date and perform an arithmetic function on a date:
olddate=$(head -1 myfile | cut -c 24-29)
newdate=$(date -d "20${olddate} + 2 days" "+%y%m%d")You may have to implement some logic if the year is before this century, e.g 1999. For the rest I suggest you look into awk or sed to perform a string replacement based on character position.
Edited by: Dude on Aug 7, 2012 12:57 PM -
Formatting DATEs with FORMAT clause and not with "to_date()" ?
Well I know I could format a DATE inline with the to_date() function.
But is there a way to format it in a separate FORMAT clause similar to
numbers?
If yes how would a format of
dd.mm.yyyy
or
yyyy.mm.dd hh:mm:ss
look like?user559463 wrote:
Ok, again I am searching something like
COLUMN "expiry" FORMAT "YYYY.MM.DD HH:MM:SS"No, it can only be done via TO_CHAR or NLS_DATE_FORMAT. I think you should read SQL*Plus COLUMN command.
SY. -
Errros in formatting dates with milliseconds
I am writing a routine to convert a String to a Date.
I have created the following mask: "yyyy-MM-dd HH:mm:ss.SSSSS"
I pass this to SimpleDateFormat and then parse to return a java.util.Date.
The method works fine when the milliseconds are all zero, ie .00012. however when the milliseconds increase, the resuting time in the date object becomes anywhere from a minute to hours later than it should be.
For instance, "2006-09-28 10:23:16.214500" becomes
Thu Sep 28 10:26:50 EDT 2006 when the resulting date object is displayed.
Is this a bug with java 1.5?OK thanks, so how would I convert the date string
provided, keeping the millisecond presision? What is
that number if not 21% of a second?Let's say you can get the fractional part (0.214500) into a double variable called fractionalSeconds. You do that part.
int milliseconds = (int) (fractionalSeconds * 1000); // or you might want to round this off - you figure that out
Now you have the number of milliseconds int the above variable. Format your timestamp using the original time string (less the fractional part) plus "." plus milliseconds. Then you could use the parser on that.
That said, I bet you could just get the timestamp as a Java date/time directly rather than parsing it as a string, since you mentioned you're getting this from a database query. -
Change formatting dates with GREP
I am laying out a book with thusands of dates all formatted e.g 02-03-1913. I want to hange these to (eg) 2nd March 1913. I expected it to be a lengthy, staged, operation. But I cannot get GREP to recognise specific numbers (e.g. 02) If worked through logically I did think I could do it in stages. Can anyone help?
Hi,
Using Multi-Find/Change, 12 regex, 1 set. So, 1 click and done!
1/ Search: (0?)(\d+)-01-(\d{4})
Replace by: $2~Sjanuary~S$3
2/ Search: (0?)(\d+)-02-(\d{4})
Replace by: $2~Sfebruary~S$3
12/ Search: (0?)(\d+)-12-(\d{4})
Replace by: $2~Sdecember~S$3 -
Problem with formatting date with JSTL ans swedish locale
Hi,
I have a strange problem with JSTL fmt:formatDate -tag and swedish locale.
-------------------------- Extract from the JSP ------------------------------
<jsp:useBean id="date" class="java.util.Date" />
<fmt:formatDate value="${date}" pattern="dd.MM.yyyy HH:mm" />
With en_US and fi_FI locales date is printed just the way I want: 29.04.2005 13:28 but in se_SE locale it is printed: Fri Apr 29 13:30:09 EEST 2005
Has anyone had this problem before?
Thanks in advance!Hi
Try using "sv_SE" locale. -
Help! using FM for formating date with to_char()
Hi,
Basically my requirement is to format the date in specific format (i.e. DD MM YYYY HH24:MM) and it should avoid the padding zeros.
Ex: 03-Jun-2009 10:01 should be displayed as 3 Jun 2009 10:01.
I was using the below query
to_char(sr.recievedat, 'FMDD Mon yyyy HH24:MI')...
But the thing is it removing the padding zeros from minuites aswell, which i dont require.
For example,
Ex1: 03-Dec-2009 18:10 3 Dec 2009 18:10
*04-Dec-2009 19:01 4 Dec 2009 19:1.. It should be 4 Dec 2009 19:01*
Can some body help me how to control the FM to restrict the padding to some places
Thanks
PhaniHi try this
sql> select to_char(sr.recievedat, 'FMDD Mon yyyy fmHH24:MI') from dual;example
SQL> select to_char(to_date('01-jan-2009 7:01:06','dd-mon-rrrr HH:MI:SS'), 'FMDD Mon yyyy fmHH24:MI'
) from dual;
TO_CHAR(TO_DATE('01-JAN
1 Jan 2009 07:01 -
Formating dates with to_char function
Hi,,
Inside a pl/sql procedure Im formating a date:
v_start_date := 2011-04-01 05:00:00;
v_start_month := to_char(v_start_date,'mm');and I need that v_start_month returns = 04
but returns 4
What could I do to fix it
Many Thanks..If you define v_start_month as a number then it will strip off the leading 0 when it displays. Define v_start_month as a varchar and it will display the way you want.
SQL> DECLARE
2 v_month VARCHAR2(10);
3 BEGIN
4 v_month := to_char(SYSDATE,'mm');
5 dbms_output.put_line(v_month);
6 END;
7 /
08 -
Format date with "yyww" doesn't work
Format a date to the format "yyww" doesn't work correctly for the first week of some years. It seams to be weeks that start in December that doesn't work.
DateFormat df = new SimpleDateFormat("yyww", Locale.FRANCE);
String in = "0801";
// Gives: Mon Dec 31 00:00:00 CET 2007
Date d = (Date) df.parseObject(in);
System.out.println(d);
// !? Gives: 0701
String out = df.format(d);
System.out.println(out);Any help appreciated!You're right. ISO 8601 Whichever year contains Thursday determines which year the week belongs to.
The U.S. locale plays by different rules though. At least according to GergorianCalendar, if even one day falls in the new year, it is week 01. This little program displays this:
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone;
import java.text.MessageFormat;
import javax.swing.JOptionPane;
public class CalendarTest {
public static void main(String args[]) throws UnsupportedEncodingException {
try {
if (args.length != 0) {
doYear(new Integer(args[0]).intValue());
return;
} catch (NumberFormatException nfe) {
doYear(2005);
doYear(1998);
doYear(1993);
* Method main
* @param args
public static void doYear(int year) throws UnsupportedEncodingException {
System.out.println();
System.out.println(year);
GregorianCalendar a = new GregorianCalendar(TimeZone.getTimeZone("GMT-8"), Locale.US);
GregorianCalendar b = new GregorianCalendar(TimeZone.getTimeZone("GMT+1"), Locale.GERMANY);
a.set(Calendar.YEAR, year);
a.set(Calendar.MONTH, Calendar.JANUARY);
a.set(Calendar.DAY_OF_MONTH, 1);
b.set(Calendar.YEAR, year);
b.set(Calendar.MONTH, Calendar.JANUARY);
b.set(Calendar.DAY_OF_MONTH, 1);
while (a.get(Calendar.DAY_OF_WEEK) != a.getFirstDayOfWeek()) {
a.add(Calendar.DAY_OF_MONTH, -1);
while (b.get(Calendar.DAY_OF_WEEK) != b.getFirstDayOfWeek()) {
b.add(Calendar.DAY_OF_MONTH, -1);
do {
System.out.println("US: " + a.getTime() + " " + a.get(Calendar.WEEK_OF_YEAR));
a.add(Calendar.DAY_OF_MONTH, 1);
} while (a.get(Calendar.DAY_OF_MONTH) != 8);
System.out.println();
do {
System.out.println("DE: " + b.getTime() + " " + b.get(Calendar.WEEK_OF_YEAR));
b.add(Calendar.DAY_OF_MONTH, 1);
} while (b.get(Calendar.DAY_OF_MONTH) != 8);
}
Maybe you are looking for
-
SSIS running through SQL Server agent Job Fails --SQL Server 2012
Hi All, I am getting the below error. Executed as user: sak\thiru. ...ion 11.0.2100.60 for 64-bit Copyright (C) Microsoft Corporation. All rights reserved. Started: 3:31:17 PM Error: 2014-03-07 15:32:22.46 Code: 0xC0202009 Source: Commo
-
Change default value "Number of Search Results" - Component PPM_DYNSEARCH
Hi Gurus, I am new to SAP CRM WebUI development and hope you can help me on following problem. In Pipeline & Performance Management we want to change the default value for the search results from 100 to 1000. SAP CRM 7.0 Component: PPM_DYNSEARCH View
-
HT201269 second hand iPhone 5 help please.
If I buy a second hand iPhone 5 (unblocked) on ios 6 and the previous owner doesn't have/won't give me/can't give me his Apple ID is there anyway I can use this phone?
-
JCo nested context with independent stateful calls
Hi experts, is it possible to make independent nested stateful calls to two or more destinations? The following sample code runs on a SAP WAS 7.10 and should visualize the problem: JCoDestination abapDest1 = JCoDestinationManager.getDestination(
-
ITS Content Cannot Sync Because Apple TV could not contact the iTune Store
No wonder it's still a hobby. Once again, I woke up to discover that all my synced iTS content had simply disappeared from my Apple TVs [third time this has happened with over 100gb of content), and neither one of them was appearing in my iTunes "con