my.getServerTime

Get current server time in milliseconds

Sample Code

copy
<!-- API-DEMO page/API/get-server-time/get-server-time.axml-->
<view class="page">
  <view class="page-section">
    <view class="page-section-btns">
      <view onTap="getServerTime">Get server time </view>
    </view>
  </view>
</view>
copy
// API-DEMO page/API/get-server-time/get-server-time.js
Page({
  getServerTime(){
    my.getServerTime({
      success: (res) => {
        my.alert({
          content: res.time,
        });
      },
    });
  }
})

Parameters

Object type with the following attributes:

PropertyType

Required

Description
successFunctionNoCallback function upon call success.
failFunctionNoCallback function upon call failure.
completeFunctionNoCallback function upon call completion (to be executed upon either call success or failure).

Success Callback Function

The incoming parameter is of the Object type with the following attributes:

PropertyTypeDescription
timeNumberGet current server time. A numerical value is returned, indicating the milliseconds since 0:0:0 January 1 1970 (UTC).