News:

This week IPhone 15 Pro winner is karn
You can be too a winner! Become the top poster of the week and win valuable prizes.  More details are You are not allowed to view links. Register or Login 

Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - zaynoun

#1
W800i - 900/1800/1900 MHz for International
W800c - 900/1800/1900 MHz for China market

General Network GSM 900 / GSM 1800 / GSM 1900
Announced 2005, 1Q
Status Available
Size Dimensions 100 x 46 x 20.5 mm
Weight 99 g
Display Type TFT, 256K colors
Size 176 x 220 pixels, 28 x 35 mm
  - Wallpapers, screensavers
Ringtones Type Polyphonic (40 channels), MP3
Customization Composer, download, order now
Vibration  Yes
Memory Phonebook 500 x 20 fields, Photo call
Call records 30 received, dialed and missed calls
Card slot Memory Stick Duo Pro, 512 MB card included, buy memory
  - 34 MB shared memory
Data GPRS Class 10 (4+1/3+2 slots), 32 - 48 kbps
HSCSD No
EDGE No
3G No
WLAN No
Bluetooth Yes, v2.0
Infrared port Yes
USB Yes
Features Messaging SMS, EMS, MMS, Email, Instant Messaging
Browser WAP 2.0/xHTML
Games Yes + downloadable, order now
Colors Smooth White
Camera 2 MP, 1632x1224 pixels, autofocus, video, flash
  - MP3/AAC player, up to 30h playback if the phone is switched off
- Video player
- Java
- T9
- FM radio with RDS
- Image viewer
- Picture editor
- Organiser
- Voice memo
- SyncML
- Built-in handsfree
Battery   Standard battery, Li-Po 900 mAh (BST-36)
Stand-by Up to 400 h
Talk time Up to 9 h

Disclaimer. We can not guarantee that the information on this page is 100% correct. Read more

source You are not allowed to view links. Register or Login
#2
 Calculating the difference between two dates

Calculating the difference between two dates in JavaScript is relatively straightforward, provided you choose the right Date methods to work with. Whichever way you get there, the potential applications on date differences are many, from counting down to a particular event, counting up from a past date, to dynamically indicating what's new on your page. Sounds like fun!

Lets begin this tutorial by getting to the heart of it:

Date.getTime()

For the scripts that follow, the above is our hero people, not some Hollywood actor. Date.getTime() is a prebuilt JS method that returns the time elapsed from January 1st, 1970 to the current Date instance, in milliseconds. Its superpower is not so much its long term memory, as impressive as that may be, but its knack for converting a date to a number (in milliseconds, but nevertheless). And we all know the easiest subjects to perform arithmetic on are numbers.

So here's the general premise for calculating the difference between two dates- convert both dates to a number using Date.getTime(), and subtract! To a few examples now.

-Calculating days remaining until Christmas:

<script>

//Set the two dates
today=new Date()
var christmas=new Date(today.getFullYear(), 11, 25) //Month is 0-11 in JavaScript
if (today.getMonth()==11 && today.getDate()>25) //if Christmas has passed already
christmas.setFullYear(christmas.getFullYear()+1) //calculate next year's Christmas
//Set 1 day in milliseconds
var one_day=1000*60*60*24

//Calculate difference btw the two dates, and convert to days
document.write(Math.ceil((christmas.getTime()-today.getTime())/(one_day))+
" days left until Christmas!")

</script>
Example: 26 days left until Christmas!

Notice how the year for "Christmas" is dynamically set to the current year (or nextyear if Christmas has already passed for this year), so the script is reusable now and in the future as well without having to modify it.

-Calculating time expired since the Millennium (Jan 1st, 2000)

We all remember the Millennium and perhaps even the parties we attended. The following shows how many days has elapsed since then (count up):

<script>

//Set the two dates
var millennium =new Date(2000, 0, 1) //Month is 0-11 in JavaScript
today=new Date()
//Get 1 day in milliseconds
var one_day=1000*60*60*24

//Calculate difference btw the two dates, and convert to days
document.write(Math.ceil((today.getTime()-millennium.getTime())/(one_day))+
" days has gone by since the millennium!")

</script>
Example: 1795 days has gone by since the millennium!

-Dynamically indicating what's new on your page:

Finally, how about displaying a "new" image alongside new content that will automatically disappear (the image, that is) after the specified future date has been reached? The logic is simple enough- if the current date is less than the specified future date, write out the "new" image:

<script>

var newimage='<img src="news.gif">'
var today=new Date()

function whatsnew(yr,mon,day){
var expire=new Date(yr,mon,day)
if (today.getTime()<=expire.getTime())
document.write(newimage)
}

</script>

<!--"New" image will disappear after Dec 30th, 2002-->
<script>whatsnew(2002,11,30)</script> This is new content!
Example: This is new content!

Conclusion

As you can see, it's not difficult at all to do arithmetic on dates in JavaScript, and in the process, derive a whole bunch of useful applications out of it.


End of tutorial

SOURCE You are not allowed to view links. Register or Login