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:

AttributesTypeMandatoryDescription
successFunctionNoCallback function for call success
failFunctionNoCallback function for call failure
completeFunctionNoCallback function for call completion (to be executed for both call success and failure)

Success Callback Function

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

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