Solved

toUTCString -- parse the parts of the date

Posted on 2011-03-18
4
455 Views
Last Modified: 2012-06-27
I was trying to convert my date to GMT and then get each individual date part but it won't let me use the normal getMonth, getDate, etc--I'm guessing because it converted the date to a string?   How can I get the individual parts of the date like my code below the following 2 lines?   The date has to be in GMT.

dteDate = new Date();
dteDate = dteDate.toUTCString();


// this is how i originally broke the date apart before converting to GMT      
var dteMonth = dteDate.getMonth() + 1;
var dteDay = dteDate.getDate();
var dteYear = dteDate.getYear();
var dteHours = dteDate.getHours();
var dteMin = dteDate.getMinutes();
var dteSec = dteDate.getSeconds();
0
Comment
Question by:saturation
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 35168385
0
 
LVL 82

Expert Comment

by:leakim971
ID: 35168391
dteDate = new Date();
dteDate = formatDate(d);

Open in new window

0
 
LVL 82

Expert Comment

by:leakim971
ID: 35168395
oups
dteDate = new Date();
dteDate = formatDate(dteDate);

Open in new window

0
 

Author Closing Comment

by:saturation
ID: 35168615
Perfect!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question