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:
Property | Type | Required | Description |
success | Function | No | Callback function upon call success. |
fail | Function | No | Callback function upon call failure. |
complete | Function | No | Callback 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:
Property | Type | Description |
time | Number | Get current server time. A numerical value is returned, indicating the milliseconds since 0:0:0 January 1 1970 (UTC). |