logo
g Text Version
Auto
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Society & Culture
Sports
Travel & Leisure
TV & Movies

dailyclick
Bored? Games!
Postcards
Astrology
Take a Quiz
Rate My Photo

new
Journals
Folklore and Mythology
Business Coach
Marriage
Senior Living
Ethnic Beauty
Adolescence


dailyclick
All times in EST

Full Schedule
g
g JavaScript / Java Site
Editor Wanted
BellaOnline's JavaScript / Java Editor

g

Getting UTC Dates in JavaScript
Guest Author - Julie L Baumler

In a recent article we looked all the methods for getting different parts of a date and time according to the local time. Local time is whatever time and timezone the computer the user is using is set to. Here we look at the methods for getting different parts of a date and time according to UTC time. More information about UTC time is available here

For these examples, date is set to Sat, 07 Jul 2007 14:07:07 GMT using var luckyday=new Date(2007,06,07,07,07,07,07);. If you have JavaScript available in your browser, you can see a live example here.

getUTCMonth()
a number representing the month according to UTC time, 0 for January, 1 for February, ... You can use this as a key to an array of month names or add one to the number to get a human readable month
EXAMPLE: luckyday.getUTCMonth() RESULT: 6


getUTCDate()
the day of the month according to UTC time as a number from 1 to 31 according to UTC time
EXAMPLE: luckyday.getUTCDate() RESULT: 7


getUTCDay()
the day of the week according to UTC time as a number from 0 to 6 where 0 represents Sunday and 6 represents Saturday
EXAMPLE: luckyday.getUTCDay() RESULT: 6


getUTCFullYear()
returns the four digit year according to UTC time
EXAMPLE: luckyday.getUTCFullYear() RESULT: 2007


getUTCHours()
hour of the day on a 24 hour clock according to UTC time(0 to 23)
EXAMPLE: luckyday.getUTCHours() RESULT: 14


getUTCMinutes()
minutes after the hour according to UTC time(0 to 59)
EXAMPLE: luckyday.getUTCMinutes() RESULT: 7


getUTCSeconds()
seconds of the minute according to UTC time(0 to 59)
EXAMPLE: luckyday.getUTCSeconds() RESULT: 7


getUTCMilliseconds()
millionths of a second according to UTC time(0 to 999)
EXAMPLE: luckyday.getUTCMilliseconds() RESULT: 7

This site needs an editor - click to learn more!

Introduction To The JavaScript Date Object
Introduction To UTC Dates
Getting Dates In Local Time
RSS
Related Articles
Previous Features
Site Map

Add Getting+UTC+Dates+in+JavaScript to Twitter Add Getting+UTC+Dates+in+JavaScript to Facebook Add Getting+UTC+Dates+in+JavaScript to MySpace Add Getting+UTC+Dates+in+JavaScript to Del.icio.us Digg Getting+UTC+Dates+in+JavaScript Add Getting+UTC+Dates+in+JavaScript to Yahoo My Web Add Getting+UTC+Dates+in+JavaScript to Google Bookmarks Add Getting+UTC+Dates+in+JavaScript to Stumbleupon Add Getting+UTC+Dates+in+JavaScript to Reddit


Content copyright © 2009 by Julie L Baumler. All rights reserved.
This content was written by Julie L Baumler. If you wish to use this content in any manner, you need written permission. Contact BellaOnline Administration for details.

g


For FREE email updates, subscribe to the JavaScript / Java Newsletter


Past Issues


print
Printer Friendly
bookmark
Bookmark
tell friend
Tell a Friend
forum
Forum
email
Email Editor

g features
Hearing Dog Tool - Adding Randomness

Hearing Dog Training Tool – setTimeout()

GCJ - an Independant Java Implementation

Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter

jobs
what
job title, keywords
where
city, state or zip
jobs by job search


vote
Growing a Garden
Veggies and Flowers
Veggies Only
Flowers Only
No Garden

g


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2009 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor