Page 16 - JavaScript
P. 16

Get the current month                                                                               213

        Get the current day                                                                                 213

        Get the current hour                                                                                213

        Get the current minutes                                                                             213

        Get the current seconds                                                                             213


        Get the current milliseconds                                                                        214

        Convert the current time and date to a human-readable string                                        214

          Create a new Date object                                                                           214

        Exploring dates                                                                                     215

          Convert to JSON                                                                                    216


          Creating a Date from UTC                                                                           216

          The problem                                                                                        216

            Naive approach with WRONG results                                                                217
            Correct approach                                                                                 217

          Creating a Date from UTC                                                                           218

          Changing a Date object                                                                             218


          Avoiding ambiguity with getTime() and setTime()                                                    218

            Convert to a string format                                                                       219

        Convert to String                                                                                   219

        Convert to Time String                                                                              219

        Convert to Date String                                                                              219

        Convert to UTC String                                                                               220

        Convert to ISO String                                                                               220


        Convert to GMT String                                                                               220

        Convert to Locale Date String                                                                       220

          Increment a Date Object                                                                            221

          Get the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC                           222

          Formatting a JavaScript date                                                                       222


        Formatting a JavaScript date in modern browsers                                                     222

          How to use                                                                                         223
   11   12   13   14   15   16   17   18   19   20   21