wxWidgets: Time

| Version: 3.2.7

Functions
Time
Functions and Macros by Category

## Detailed Description

The functions in this section deal with getting the current time and sleeping for the specified time interval.

## Functions
int | wxGetTimeZone ()
| Returns the difference between UTC and local time in seconds. More...
long | wxGetLocalTime ()
| Returns the number of seconds since local time 00:00:00 Jan 1st 1970. More...
wxLongLong | wxGetLocalTimeMillis ()
| Returns the number of milliseconds since local time 00:00:00 Jan 1st 1970. More...
long | wxGetUTCTime ()
| Returns the number of seconds since GMT 00:00:00 Jan 1st 1970. More...
wxLongLong | wxGetUTCTimeMillis ()
| Returns the number of milliseconds since GMT 00:00:00 Jan 1st 1970. More...
wxLongLong | wxGetUTCTimeUSec ()
| Returns the number of microseconds since GMT 00:00:00 Jan 1st 1970. More...
void | wxMicroSleep (unsigned long microseconds)
| Sleeps for the specified number of microseconds. More...
void | wxMilliSleep (unsigned long milliseconds)
| Sleeps for the specified number of milliseconds. More...
wxString | wxNow ()
| Returns a string representing the current date and time. More...
void | wxSleep (int secs)
| Sleeps for the specified number of seconds. More...
void | wxUsleep (unsigned long milliseconds)

## Function Documentation

## ◆ wxGetLocalTime()

long wxGetLocalTime | ( |  | ) |

Returns the number of seconds since local time 00:00:00 Jan 1st 1970.

See also
  wxDateTime::Now()

Include file:

    #include <wx/time.h>

## ◆ wxGetLocalTimeMillis()

wxLongLong wxGetLocalTimeMillis | ( |  | ) |

Returns the number of milliseconds since local time 00:00:00 Jan 1st 1970.

The use of wxGetUTCTimeMillis() is preferred as it provides a usually (except for changes to the system time) monotonic clock which the local time also changes whenever DST begins or ends.

See also
  wxDateTime::Now(), wxGetUTCTimeMillis(), wxGetUTCTimeUSec()

Include file:

    #include <wx/time.h>

## ◆ wxGetTimeZone()

int wxGetTimeZone | ( |  | ) |

Returns the difference between UTC and local time in seconds.

This function intentionally doesn't take DST into account, i.e. the offset returned is the same one independently of when the function is called.

Include file:

    #include <wx/time.h>

## ◆ wxGetUTCTime()

long wxGetUTCTime | ( |  | ) |

Returns the number of seconds since GMT 00:00:00 Jan 1st 1970.

See also
  wxDateTime::Now()

Include file:

    #include <wx/time.h>

## ◆ wxGetUTCTimeMillis()

wxLongLong wxGetUTCTimeMillis | ( |  | ) |

Returns the number of milliseconds since GMT 00:00:00 Jan 1st 1970.

Include file:

    #include <wx/time.h>

Since
  2.9.3

## ◆ wxGetUTCTimeUSec()

wxLongLong wxGetUTCTimeUSec | ( |  | ) |

Returns the number of microseconds since GMT 00:00:00 Jan 1st 1970.

Include file:

    #include <wx/time.h>

Since
  2.9.3

## ◆ wxMicroSleep()

void wxMicroSleep | ( | unsigned long | microseconds | ) |

Sleeps for the specified number of microseconds.

The microsecond resolution may not, in fact, be available on all platforms (currently only Unix platforms with nanosleep(2) may provide it) in which case this is the same as calling wxMilliSleep() with the argument of microseconds/1000.

Include file:

    #include <wx/utils.h>

## ◆ wxMilliSleep()

void wxMilliSleep | ( | unsigned long | milliseconds | ) |

Sleeps for the specified number of milliseconds.

Notice that usage of this function is encouraged instead of calling usleep(3) directly because the standard usleep() function is not MT safe.

Include file:

    #include <wx/utils.h>

## ◆ wxNow()

wxString wxNow | ( |  | ) |

Returns a string representing the current date and time.

Include file:

    #include <wx/utils.h>

## ◆ wxSleep()

void wxSleep | ( | int | secs | ) |

Sleeps for the specified number of seconds.

Include file:

    #include <wx/utils.h>

## ◆ wxUsleep()

void wxUsleep | ( | unsigned long | milliseconds | ) |

Deprecated:
  This function is deprecated because its name is misleading: notice that the argument is in milliseconds, not microseconds.

Please use either wxMilliSleep() or wxMicroSleep() depending on the resolution you need.

Sleeps for the specified number of milliseconds.

Include file:

    #include <wx/utils.h>