ZKLibrary icon indicating copy to clipboard operation
ZKLibrary copied to clipboard

How to sync PC current time to device

Open Meemkhaan opened this issue 5 years ago • 15 comments

Dear Sir Kamshory, please guide me in to sync PC current time to device. i'm not much familiar to development but i can re-code basic applications.

Meemkhaan avatar Jul 30 '19 07:07 Meemkhaan

To synchronize attendance data between the device and PC, you need to create a database on a PC. Because the device cannot do push data, the PC must pull data periodically. After the attendance data has been successfully entered into the database, delete attendance data on the device. Don't forget to disable the device during this process to ensure that no attendance data is deleted because the user checks the device during this process. You also have to feed user data to the database according to the data on the device.

kamshory avatar Jul 30 '19 09:07 kamshory

dear, my means to sync date and time from pc not data from pc

Meemkhaan avatar Jul 30 '19 09:07 Meemkhaan

$zk->setTime("2019-07-30 23:54:51");

kamshory avatar Jul 30 '19 11:07 kamshory

image

Meemkhaan avatar Jul 30 '19 11:07 Meemkhaan

+923422251896 this is my whatsapp# i just need your few minutes because tomorrow is end of my given deadline to submit the project.

Meemkhaan avatar Jul 30 '19 11:07 Meemkhaan

What is code on file zkconst.php?

kamshory avatar Jul 30 '19 11:07 kamshory

image

function encode_time($t) { /*Encode a timestamp send at the timeclock

    copied from zkemsdk.c - EncodeTime*/
    $d = ( ($t->year % 100) * 12 * 31 + (($t->month - 1) * 31) + $t->day - 1) *
         (24 * 60 * 60) + ($t->hour * 60 + $t->minute) * 60 + $t->second;

    return $d;
}

function decode_time($t) {
    /*Decode a timestamp retrieved from the timeclock

    copied from zkemsdk.c - DecodeTime*/
    $second = $t % 60;
    $t = $t / 60;

    $minute = $t % 60;
    $t = $t / 60;

    $hour = $t % 24;
    $t = $t / 24;

    $day = $t % 31+1;
    $t = $t / 31;

    $month = $t % 12+1;
    $t = $t / 12;

    $year = floor( $t + 2000 );

    $d = date("Y-m-d H:i:s", strtotime( $year.'-'.$month.'-'.$day.' '.$hour.':'.$minute.':'.$second) );
    
    return $d;
}

Meemkhaan avatar Jul 30 '19 11:07 Meemkhaan

Can I see your own code when you call $zk->setTime()?

kamshory avatar Jul 30 '19 11:07 kamshory

Wait... What library do you used? My library is https://github.com/kamshory/ZKLibrary/blob/master/zklibrary.php

kamshory avatar Jul 30 '19 12:07 kamshory

<?php
include "zklibrary.php";
$zk = new ZKLibrary('192.168.1.102', 4370);
$zk->connect();
$zk->disableDevice();
$zk->setTime(date("Y-m-d H:i:s"));
$zk->testVoice();
$zk->enableDevice();
$zk->disconnect();
?>

https://github.com/kamshory/ZKLibrary/blob/master/README.md

kamshory avatar Jul 30 '19 12:07 kamshory

thank you so much dear, but accidentally i'm using another zklibrary which is in parts. image

Meemkhaan avatar Jul 30 '19 13:07 Meemkhaan

No. That is not mine.

kamshory avatar Jul 31 '19 02:07 kamshory

Make sure you only use https://github.com/kamshory/ZKLibrary/blob/master/zklibrary.php

kamshory avatar Jul 31 '19 02:07 kamshory

yes dear its not your library. it is from vodvud and it is a very faster to load. thanks for your help. although it is very helpful for me.

Meemkhaan avatar Jul 31 '19 06:07 Meemkhaan

@Meemkhaan I already figure out how it works. I also add the default timezone and set the time.

date_default_timezone_set('Asia/Manila'); //Your Default Timezone
$zk->setTime(date('Y-m-d H:i:s'));

https://github.com/vodvud/php_zklib/issues/16

aice09 avatar Aug 09 '19 03:08 aice09